public class WKTReader
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
LINESTRING
known WKT type LINESTRING
|
static java.lang.String |
MULTILINESTRING
known WKT type MULTILINESTRING
|
static java.lang.String |
POINT
known WKT type POINT
|
| Constructor and Description |
|---|
WKTReader() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
init(java.io.Reader input)
Initialize the reader to use a certain input reader
|
protected boolean |
isDone()
Returns true if the whole file has been read
|
protected boolean |
isKnownType(java.lang.String type)
Returns true if type is one of the known WKT types
|
protected java.lang.String |
nextType()
Returns the next type read from the reader given at init or null
if no more types can be read
|
protected java.util.List<Coord> |
parseLineString(java.lang.String line)
Parses coordinate tuples from "LINESTRING" lines
|
protected java.util.List<java.util.List<Coord>> |
parseMultilinestring()
Parses a MULTILINESTRING statement that has nested linestrings from
the current reader
|
protected Coord |
parsePoint()
Parses a WKT point data from the intialized reader
|
java.util.List<java.util.List<Coord>> |
readLines(java.io.File file)
Read line (LINESTRING) data from a file
|
java.lang.String |
readNestedContents()
Returns nested contents from the reader given at init
|
java.lang.String |
readNestedContents(java.io.Reader r)
Reads everything from the first opening parenthesis until line that
ends to a closing parenthesis and returns the contents in one string
|
java.util.List<Coord> |
readPoints(java.io.File file)
Read point data from a file
|
java.util.List<Coord> |
readPoints(java.io.Reader r)
Read point data from a Reader
|
protected java.lang.String |
readWord(java.io.Reader r)
Reads a "word", ie whitespace delimited string of characters, from
the reader
|
protected void |
setDone(boolean done)
Sets the "is file read" state
|
protected char |
skipAllWhitespace(java.io.Reader r)
Skips all consecutive whitespace characters from reader
|
protected void |
skipUntil(java.io.Reader r,
char until)
Reads and skips all characters until character "until" is read or
end of stream is reached.
|
public static final java.lang.String LINESTRING
public static final java.lang.String MULTILINESTRING
public static final java.lang.String POINT
public java.util.List<Coord> readPoints(java.io.File file) throws java.io.IOException
file - The file to read points fromjava.io.IOException - if something went wrong while readingpublic java.util.List<Coord> readPoints(java.io.Reader r) throws java.io.IOException
r - The Reader to read points fromjava.io.IOException - if something went wrong while readingpublic java.util.List<java.util.List<Coord>> readLines(java.io.File file) throws java.io.IOException
file - The file to read data fromjava.io.IOException - if something went wrong while readingprotected void init(java.io.Reader input)
input - The input to useprotected java.lang.String nextType()
throws java.io.IOException
java.io.IOExceptionprotected boolean isKnownType(java.lang.String type)
type - The type to checkprotected java.lang.String readWord(java.io.Reader r)
throws java.io.IOException
r - Reader to read the characters fromjava.io.IOExceptionprotected java.util.List<java.util.List<Coord>> parseMultilinestring() throws java.io.IOException
java.io.IOExceptionprotected Coord parsePoint() throws java.io.IOException
java.io.IOException - if couldn't parse coordinate valuesprotected void skipUntil(java.io.Reader r,
char until)
throws java.io.IOException
r - Reader to read characters fromuntil - What character to expectjava.io.IOExceptionprotected char skipAllWhitespace(java.io.Reader r)
throws java.io.IOException
r - Reader where the whitespace is skippedjava.io.IOExceptionpublic java.lang.String readNestedContents(java.io.Reader r)
throws java.io.IOException
r - Reader to read the input fromjava.io.IOExceptionpublic java.lang.String readNestedContents()
throws java.io.IOException
java.io.IOExceptionreadNestedContents(Reader)protected java.util.List<Coord> parseLineString(java.lang.String line)
line - String that contains the whole "LINESTRING"'s contentprotected boolean isDone()
protected void setDone(boolean done)
done - If true, reading is done