Package org.geotools.geometry.jts
Class WKTWriter2
-
public class WKTWriter2 extends WKTWriter
A fork of JTS ownWKTWriterthat can write curved geometries using SQL Multi-Media Extension Well-Known Text- See Also:
WKTReader2
-
-
Constructor Summary
Constructors Constructor Description WKTWriter2()Creates a new WKTWriter with default settingsWKTWriter2(int outputDimension)Creates a writer that writesGeometrys with the given output dimension (2 or 3).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetFormatted(boolean isFormatted)Sets whether the output will be formatted.voidsetMaxCoordinatesPerLine(int coordsPerLine)Sets the maximum number of coordinates per line written in formatted output.voidsetTab(int size)Sets the tab size to use for indenting.static StringstringOfChar(char ch, int count)Returns aStringof repeated characters.static StringtoLineString(Coordinate p0, Coordinate p1)Generates the WKT for a LINESTRING specified by twoCoordinates.static StringtoLineString(CoordinateSequence seq)Generates the WKT for a LINESTRING specified by aCoordinateSequence.static StringtoPoint(Coordinate p0)Generates the WKT for a POINT specified by aCoordinate.Stringwrite(Geometry geometry)Converts aGeometryto its Well-known Text representation.voidwrite(Geometry geometry, Writer writer)Converts aGeometryto its Well-known Text representation.StringwriteFormatted(Geometry geometry)Same aswrite, but with newlines and spaces to make the well-known text more readable.voidwriteFormatted(Geometry geometry, Writer writer)Same aswrite, but with newlines and spaces to make the well-known text more readable.-
Methods inherited from class WKTWriter
format, getOutputOrdinates, setOutputOrdinates, setPrecisionModel, toLineString
-
-
-
-
Constructor Detail
-
WKTWriter2
public WKTWriter2()
Creates a new WKTWriter with default settings
-
WKTWriter2
public WKTWriter2(int outputDimension)
Creates a writer that writesGeometrys 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 notDouble.NaN).- Parameters:
outputDimension- the coordinate dimension to output (2 or 3)
-
-
Method Detail
-
toPoint
public static String toPoint(Coordinate p0)
Generates the WKT for a POINT specified by aCoordinate.- Parameters:
p0- the point coordinate- Returns:
- the WKT
-
toLineString
public static String toLineString(CoordinateSequence seq)
Generates the WKT for a LINESTRING specified by aCoordinateSequence.- Parameters:
seq- the sequence to write- Returns:
- the WKT string
-
toLineString
public static String toLineString(Coordinate p0, Coordinate p1)
Generates the WKT for a LINESTRING specified by twoCoordinates.- Parameters:
p0- the first coordinatep1- the second coordinate- Returns:
- the WKT
-
stringOfChar
public static String stringOfChar(char ch, int count)
Returns aStringof repeated characters.- Parameters:
ch- the character to repeatcount- the number of times to repeat the character- Returns:
- a
Stringof characters
-
setFormatted
public void setFormatted(boolean isFormatted)
Sets whether the output will be formatted.- Overrides:
setFormattedin classWKTWriter- Parameters:
isFormatted- true if the output is to be formatted
-
setMaxCoordinatesPerLine
public void setMaxCoordinatesPerLine(int coordsPerLine)
Sets the maximum number of coordinates per line written in formatted output. If the provided coordinate number is <= 0, coordinates will be written all on one line.- Overrides:
setMaxCoordinatesPerLinein classWKTWriter- Parameters:
coordsPerLine- the number of coordinates per line to output.
-
setTab
public void setTab(int size)
Sets the tab size to use for indenting.- Overrides:
setTabin classWKTWriter- Parameters:
size- the number of spaces to use as the tab string- Throws:
IllegalArgumentException- if the size is non-positive
-
write
public String write(Geometry geometry)
Converts aGeometryto its Well-known Text representation.
-
write
public void write(Geometry geometry, Writer writer) throws IOException
Converts aGeometryto its Well-known Text representation.- Overrides:
writein classWKTWriter- Parameters:
geometry- aGeometryto process- Throws:
IOException
-
writeFormatted
public String writeFormatted(Geometry geometry)
Same aswrite, but with newlines and spaces to make the well-known text more readable.- Overrides:
writeFormattedin classWKTWriter- Parameters:
geometry- aGeometryto process- Returns:
- a
string (see the OpenGIS Simple Features Specification), with newlines and spaces
-
writeFormatted
public void writeFormatted(Geometry geometry, Writer writer) throws IOException
Same aswrite, but with newlines and spaces to make the well-known text more readable.- Overrides:
writeFormattedin classWKTWriter- Parameters:
geometry- aGeometryto process- Throws:
IOException
-
-