public class WKTWriter extends Object
Geometry. The Well-Known Text format is defined in the OGC
Simple Features Specification for SQL. See
WKTReader for a formal specification of the format syntax.
The WKTWriter outputs coordinates rounded to the precision model. Only the maximum number of decimal places necessary to represent the ordinates to the required precision will be output.
The SFS WKT spec does not define a special tag for LinearRings. Under the spec, rings are output as LINESTRINGs. In order to allow precisely specifying constructed geometries, JTS also supports a non-standard LINEARRING tag which is used to output LinearRings.
WKTReader
| Constructor and Description |
|---|
WKTWriter()
Creates a new WKTWriter with default settings
|
WKTWriter(int outputDimension)
Creates a writer that writes
Geometrys with the given output dimension (2 or 3).
|
| Modifier and Type | Method and Description |
|---|---|
void |
setFormatted(boolean isFormatted)
Sets whether the output will be formatted.
|
void |
setMaxCoordinatesPerLine(int coordsPerLine)
Sets the maximum number of coordinates per line written in formatted output.
|
void |
setTab(int size)
Sets the tab size to use for indenting.
|
static String |
stringOfChar(char ch, int count)
Returns a
String of repeated characters.
|
static String |
toLineString(Coordinate
Generates the WKT for a
LINESTRING specified by a
CoordinateSequence.
|
static String |
toLineString(Coordinate
Generates the WKT for a
LINESTRING specified by two
Coordinates.
|
static String |
toLineString(CoordinateSequence
Generates the WKT for a
LINESTRING specified by a
CoordinateSequence.
|
static String |
toPoint(Coordinate
Generates the WKT for a
POINT specified by a
Coordinate.
|
String |
write(Geometry
Converts a
Geometry to its Well-known Text representation.
|
void |
write(Geometry
Converts a
Geometry to its Well-known Text representation.
|
String |
writeFormatted(Geometry
Same as
write, but with newlines and spaces to make the well-known text more readable.
|
void |
writeFormatted(Geometry
Same as
write, but with newlines and spaces to make the well-known text more readable.
|
public WKTWriter()
public WKTWriter(int outputDimension)
Geometrys with the given output dimension (2 or 3). If the specified output dimension is 3, the Z value of coordinates will be written if it is present (i.e. if it is not
Double.NaN).
outputDimension - the coordinate dimension to output (2 or 3)
public static StringtoPoint(Coordinate p0)
Coordinate.
p0 - the point coordinate
public static StringtoLineString(CoordinateSequence seq)
CoordinateSequence.
seq - the sequence to write
public static StringtoLineString(Coordinate [] coord)
CoordinateSequence.
seq - the sequence to write
public static StringtoLineString(Coordinate p0, Coordinate p1)
Coordinates.
p0 - the first coordinate
p1 - the second coordinate
public static StringstringOfChar(char ch, int count)
String of repeated characters.
ch - the character to repeat
count - the number of times to repeat the character
String of characters
public void setFormatted(boolean isFormatted)
isFormatted - true if the output is to be formatted
public void setMaxCoordinatesPerLine(int coordsPerLine)
coordsPerLine - the number of coordinates per line to output.
public void setTab(int size)
size - the number of spaces to use as the tab string
IllegalArgumentException - if the size is non-positive
public Stringwrite(Geometry geometry)
Geometry to its Well-known Text representation.
geometry - a
Geometry to process
public void write(Geometrygeometry, Writer writer) throws IOException
Geometry to its Well-known Text representation.
geometry - a
Geometry to process
IOException
public StringwriteFormatted(Geometry geometry)
write, but with newlines and spaces to make the well-known text more readable.
geometry - a
Geometry to process
public void writeFormatted(Geometrygeometry, Writer writer) throws IOException
write, but with newlines and spaces to make the well-known text more readable.
geometry - a
Geometry to process
IOException