Package org.geotools.geometry.jts
Class WKTWriter2
A fork of JTS own
WKTWriter
that can write curved geometries using SQL Multi-Media Extension Well-Known Text- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new WKTWriter with default settingsWKTWriter2
(int outputDimension) Creates a writer that writesGeometry
s with the given output dimension (2 or 3). -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 aString
of repeated characters.static String
toLineString
(Coordinate p0, Coordinate p1) Generates the WKT for a LINESTRING specified by twoCoordinate
s.static String
Generates the WKT for a LINESTRING specified by aCoordinateSequence
.static String
toPoint
(Coordinate p0) Generates the WKT for a POINT specified by aCoordinate
.Converts aGeometry
to its Well-known Text representation.void
Converts aGeometry
to its Well-known Text representation.writeFormatted
(Geometry geometry) Same aswrite
, but with newlines and spaces to make the well-known text more readable.void
writeFormatted
(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 Details
-
WKTWriter2
public WKTWriter2()Creates a new WKTWriter with default settings -
WKTWriter2
public WKTWriter2(int outputDimension) Creates a writer that writesGeometry
s 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 Details
-
toPoint
Generates the WKT for a POINT specified by aCoordinate
.- Parameters:
p0
- the point coordinate- Returns:
- the WKT
-
toLineString
Generates the WKT for a LINESTRING specified by aCoordinateSequence
.- Parameters:
seq
- the sequence to write- Returns:
- the WKT string
-
toLineString
Generates the WKT for a LINESTRING specified by twoCoordinate
s.- Parameters:
p0
- the first coordinatep1
- the second coordinate- Returns:
- the WKT
-
stringOfChar
Returns aString
of repeated characters.- Parameters:
ch
- the character to repeatcount
- the number of times to repeat the character- Returns:
- a
String
of characters
-
setFormatted
public void setFormatted(boolean isFormatted) Sets whether the output will be formatted.- Overrides:
setFormatted
in 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:
setMaxCoordinatesPerLine
in 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:
setTab
in classWKTWriter
- Parameters:
size
- the number of spaces to use as the tab string- Throws:
IllegalArgumentException
- if the size is non-positive
-
write
Converts aGeometry
to its Well-known Text representation. -
write
Converts aGeometry
to its Well-known Text representation.- Overrides:
write
in classWKTWriter
- Parameters:
geometry
- aGeometry
to process- Throws:
IOException
-
writeFormatted
Same aswrite
, but with newlines and spaces to make the well-known text more readable.- Overrides:
writeFormatted
in classWKTWriter
- Parameters:
geometry
- aGeometry
to process- Returns:
- a
string (see the OpenGIS Simple Features Specification), with newlines and spaces
-
writeFormatted
Same aswrite
, but with newlines and spaces to make the well-known text more readable.- Overrides:
writeFormatted
in classWKTWriter
- Parameters:
geometry
- aGeometry
to process- Throws:
IOException
-