public class SVGWriter
extends java.lang.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 LinearRing
s.
Under the spec, rings are output as LINESTRING
s.
In order to allow precisely specifying constructed geometries,
JTS also supports a non-standard LINEARRING
tag which is used
to output LinearRings.
WKTReader
Modifier and Type | Field and Description |
---|---|
private int |
coordsPerLine |
private java.text.DecimalFormat |
formatter |
private static int |
INDENT |
private java.lang.String |
indentTabStr |
private boolean |
isFormatted |
private int |
level |
private int |
outputDimension |
private boolean |
useFormatting |
Constructor and Description |
---|
SVGWriter()
Creates a new SVGWriter with default settings
|
Modifier and Type | Method and Description |
---|---|
private void |
appendCoordinate(CoordinateSequence seq,
int i,
java.io.Writer writer)
Appends the i'th coordinate from the sequence to the writer
|
private void |
appendCoordinate(Coordinate coordinate,
java.io.Writer writer)
Converts a
Coordinate to <Point> format,
then appends it to the writer. |
private void |
appendGeometryCollectionTaggedText(GeometryCollection geometryCollection,
int level,
java.io.Writer writer)
Converts a
GeometryCollection to <GeometryCollection
Tagged Text> format, then appends it to the writer. |
private void |
appendGeometryCollectionText(GeometryCollection geometryCollection,
int level,
java.io.Writer writer)
Converts a
GeometryCollection to <GeometryCollectionText>
format, then appends it to the writer. |
private void |
appendGeometryTaggedText(Geometry geometry,
int level,
java.io.Writer writer)
Converts a
Geometry to <Geometry Tagged Text> format,
then appends it to the writer. |
private void |
appendLinearRingTaggedText(LinearRing linearRing,
int level,
java.io.Writer writer)
Converts a
LinearRing to <LinearRing Tagged Text>
format, then appends it to the writer. |
private void |
appendLineString(LineString lineString,
int level,
boolean doIndent,
java.io.Writer writer)
Converts a
LineString to <LineString Text> format, then
appends it to the writer. |
private void |
appendLineStringTaggedText(LineString lineString,
int level,
java.io.Writer writer)
Converts a
LineString to <LineString Tagged Text>
format, then appends it to the writer. |
private void |
appendMultiLineStringTaggedText(MultiLineString multiLineString,
int level,
java.io.Writer writer)
Converts a
MultiLineString to <MultiLineString Tagged
Text> format, then appends it to the writer. |
private void |
appendMultiLineStringText(MultiLineString multiLineString,
int level,
boolean indentFirst,
java.io.Writer writer)
Converts a
MultiLineString to <MultiLineString Text>
format, then appends it to the writer. |
private void |
appendMultiPointTaggedText(MultiPoint multipoint,
int level,
java.io.Writer writer)
Converts a
MultiPoint to <MultiPoint Tagged Text>
format, then appends it to the writer. |
private void |
appendMultiPointText(MultiPoint multiPoint,
int level,
java.io.Writer writer)
Converts a
MultiPoint to <MultiPoint Text> format, then
appends it to the writer. |
private void |
appendMultiPolygonTaggedText(MultiPolygon multiPolygon,
int level,
java.io.Writer writer)
Converts a
MultiPolygon to <MultiPolygon Tagged Text>
format, then appends it to the writer. |
private void |
appendMultiPolygonText(MultiPolygon multiPolygon,
int level,
java.io.Writer writer)
Converts a
MultiPolygon to <MultiPolygon Text> format,
then appends it to the writer. |
private void |
appendPathEnd(java.io.Writer writer) |
private void |
appendPathStart(boolean useFillRule,
java.io.Writer writer) |
private void |
appendPoint(Coordinate coordinate,
int level,
java.io.Writer writer,
PrecisionModel precisionModel)
Converts a
Coordinate to <Point Text> format, then
appends it to the writer. |
private void |
appendPointTaggedText(Coordinate coordinate,
int level,
java.io.Writer writer,
PrecisionModel precisionModel)
Converts a
Coordinate to <Point Tagged Text> format,
then appends it to the writer. |
private void |
appendPolygon(Polygon polygon,
int level,
java.io.Writer writer)
Converts a
Polygon to <Polygon Tagged Text> format,
then appends it to the writer. |
private void |
appendPolygonPath(Polygon polygon,
int level,
boolean indentFirst,
java.io.Writer writer) |
private void |
appendPolygonPolygon(Polygon polygon,
int level,
boolean indentFirst,
java.io.Writer writer)
Converts a
Polygon to <Polygon Text> format, then
appends it to the writer. |
private void |
appendSequencePath(CoordinateSequence seq,
int level,
boolean doIndent,
java.io.Writer writer)
Converts a
LineString to <LineString Text> format, then
appends it to the writer. |
private void |
appendSequencePoints(CoordinateSequence seq,
int level,
boolean doIndent,
java.io.Writer writer) |
private static java.text.DecimalFormat |
createFormatter(PrecisionModel precisionModel)
Creates the
DecimalFormat used to write double s
with a sufficient number of decimal places. |
private void |
indent(int level,
java.io.Writer writer) |
private void |
indentCoords(int coordIndex,
int level,
java.io.Writer writer) |
static java.lang.String |
stringOfChar(char ch,
int count)
Returns a
String of repeated characters. |
java.lang.String |
write(Geometry geometry)
Converts a
Geometry to its Well-known Text representation. |
void |
write(Geometry geometry,
java.io.Writer writer)
Converts a
Geometry to its Well-known Text representation. |
java.lang.String |
writeFormatted(Geometry geometry)
Same as
write , but with newlines and spaces to make the
well-known text more readable. |
private void |
writeFormatted(Geometry geometry,
boolean useFormatting,
java.io.Writer writer)
Converts a
Geometry to its Well-known Text representation. |
void |
writeFormatted(Geometry geometry,
java.io.Writer writer)
Same as
write , but with newlines and spaces to make the
well-known text more readable. |
private java.lang.String |
writeNumber(double d)
Converts a
double to a String , not in scientific
notation. |
private static final int INDENT
private int outputDimension
private java.text.DecimalFormat formatter
private boolean isFormatted
private boolean useFormatting
private int level
private int coordsPerLine
private java.lang.String indentTabStr
private static java.text.DecimalFormat createFormatter(PrecisionModel precisionModel)
DecimalFormat
used to write double
s
with a sufficient number of decimal places.precisionModel
- the PrecisionModel
used to determine
the number of decimal places to write.DecimalFormat
that write double
s without scientific notation.public static java.lang.String stringOfChar(char ch, int count)
String
of repeated characters.ch
- the character to repeatcount
- the number of times to repeat the characterString
of characterspublic java.lang.String write(Geometry geometry)
Geometry
to its Well-known Text representation.geometry
- a Geometry
to processpublic void write(Geometry geometry, java.io.Writer writer) throws java.io.IOException
Geometry
to its Well-known Text representation.geometry
- a Geometry
to processjava.io.IOException
public java.lang.String writeFormatted(Geometry geometry)
write
, but with newlines and spaces to make the
well-known text more readable.geometry
- a Geometry
to processpublic void writeFormatted(Geometry geometry, java.io.Writer writer) throws java.io.IOException
write
, but with newlines and spaces to make the
well-known text more readable.geometry
- a Geometry
to processjava.io.IOException
private void writeFormatted(Geometry geometry, boolean useFormatting, java.io.Writer writer) throws java.io.IOException
Geometry
to its Well-known Text representation.geometry
- a Geometry
to processjava.io.IOException
private void appendGeometryTaggedText(Geometry geometry, int level, java.io.Writer writer) throws java.io.IOException
Geometry
to <Geometry Tagged Text> format,
then appends it to the writer.geometry
- the Geometry
to processwriter
- the output writer to append tojava.io.IOException
private void appendPointTaggedText(Coordinate coordinate, int level, java.io.Writer writer, PrecisionModel precisionModel) throws java.io.IOException
Coordinate
to <Point Tagged Text> format,
then appends it to the writer.coordinate
- the Coordinate
to processwriter
- the output writer to append toprecisionModel
- the PrecisionModel
to use to convert
from a precise coordinate to an external coordinatejava.io.IOException
private void appendLineStringTaggedText(LineString lineString, int level, java.io.Writer writer) throws java.io.IOException
LineString
to <LineString Tagged Text>
format, then appends it to the writer.lineString
- the LineString
to processwriter
- the output writer to append tojava.io.IOException
private void appendLinearRingTaggedText(LinearRing linearRing, int level, java.io.Writer writer) throws java.io.IOException
LinearRing
to <LinearRing Tagged Text>
format, then appends it to the writer.linearRing
- the LinearRing
to processwriter
- the output writer to append tojava.io.IOException
private void appendPolygon(Polygon polygon, int level, java.io.Writer writer) throws java.io.IOException
Polygon
to <Polygon Tagged Text> format,
then appends it to the writer.polygon
- the Polygon
to processwriter
- the output writer to append tojava.io.IOException
private void appendMultiPointTaggedText(MultiPoint multipoint, int level, java.io.Writer writer) throws java.io.IOException
MultiPoint
to <MultiPoint Tagged Text>
format, then appends it to the writer.multipoint
- the MultiPoint
to processwriter
- the output writer to append tojava.io.IOException
private void appendMultiLineStringTaggedText(MultiLineString multiLineString, int level, java.io.Writer writer) throws java.io.IOException
MultiLineString
to <MultiLineString Tagged
Text> format, then appends it to the writer.multiLineString
- the MultiLineString
to processwriter
- the output writer to append tojava.io.IOException
private void appendMultiPolygonTaggedText(MultiPolygon multiPolygon, int level, java.io.Writer writer) throws java.io.IOException
MultiPolygon
to <MultiPolygon Tagged Text>
format, then appends it to the writer.multiPolygon
- the MultiPolygon
to processwriter
- the output writer to append tojava.io.IOException
private void appendGeometryCollectionTaggedText(GeometryCollection geometryCollection, int level, java.io.Writer writer) throws java.io.IOException
GeometryCollection
to <GeometryCollection
Tagged Text> format, then appends it to the writer.geometryCollection
- the GeometryCollection
to processwriter
- the output writer to append tojava.io.IOException
private void appendPoint(Coordinate coordinate, int level, java.io.Writer writer, PrecisionModel precisionModel) throws java.io.IOException
Coordinate
to <Point Text> format, then
appends it to the writer.coordinate
- the Coordinate
to processwriter
- the output writer to append toprecisionModel
- the PrecisionModel
to use to convert
from a precise coordinate to an external coordinatejava.io.IOException
private void appendCoordinate(CoordinateSequence seq, int i, java.io.Writer writer) throws java.io.IOException
seq
- the CoordinateSequence
to processi
- the index of the coordinate to writewriter
- the output writer to append tojava.io.IOException
private void appendCoordinate(Coordinate coordinate, java.io.Writer writer) throws java.io.IOException
Coordinate
to <Point>
format,
then appends it to the writer.coordinate
- the Coordinate
to processwriter
- the output writer to append tojava.io.IOException
private java.lang.String writeNumber(double d)
double
to a String
, not in scientific
notation.d
- the double
to convertdouble
as a String
, not in
scientific notationprivate void appendSequencePath(CoordinateSequence seq, int level, boolean doIndent, java.io.Writer writer) throws java.io.IOException
LineString
to <LineString Text> format, then
appends it to the writer.lineString
- the LineString
to processwriter
- the output writer to append tojava.io.IOException
private void appendSequencePoints(CoordinateSequence seq, int level, boolean doIndent, java.io.Writer writer) throws java.io.IOException
java.io.IOException
private void appendLineString(LineString lineString, int level, boolean doIndent, java.io.Writer writer) throws java.io.IOException
LineString
to <LineString Text> format, then
appends it to the writer.lineString
- the LineString
to processwriter
- the output writer to append tojava.io.IOException
private void appendPolygonPolygon(Polygon polygon, int level, boolean indentFirst, java.io.Writer writer) throws java.io.IOException
Polygon
to <Polygon Text> format, then
appends it to the writer.polygon
- the Polygon
to processwriter
- the output writer to append tojava.io.IOException
private void appendPolygonPath(Polygon polygon, int level, boolean indentFirst, java.io.Writer writer) throws java.io.IOException
java.io.IOException
private void appendPathStart(boolean useFillRule, java.io.Writer writer) throws java.io.IOException
java.io.IOException
private void appendPathEnd(java.io.Writer writer) throws java.io.IOException
java.io.IOException
private void appendMultiPointText(MultiPoint multiPoint, int level, java.io.Writer writer) throws java.io.IOException
MultiPoint
to <MultiPoint Text> format, then
appends it to the writer.multiPoint
- the MultiPoint
to processwriter
- the output writer to append tojava.io.IOException
private void appendMultiLineStringText(MultiLineString multiLineString, int level, boolean indentFirst, java.io.Writer writer) throws java.io.IOException
MultiLineString
to <MultiLineString Text>
format, then appends it to the writer.multiLineString
- the MultiLineString
to processwriter
- the output writer to append tojava.io.IOException
private void appendMultiPolygonText(MultiPolygon multiPolygon, int level, java.io.Writer writer) throws java.io.IOException
MultiPolygon
to <MultiPolygon Text> format,
then appends it to the writer.multiPolygon
- the MultiPolygon
to processwriter
- the output writer to append tojava.io.IOException
private void appendGeometryCollectionText(GeometryCollection geometryCollection, int level, java.io.Writer writer) throws java.io.IOException
GeometryCollection
to <GeometryCollectionText>
format, then appends it to the writer.geometryCollection
- the GeometryCollection
to processwriter
- the output writer to append tojava.io.IOException
private void indentCoords(int coordIndex, int level, java.io.Writer writer) throws java.io.IOException
java.io.IOException
private void indent(int level, java.io.Writer writer) throws java.io.IOException
java.io.IOException