Package org.locationtech.jtstest.util.io
Class SVGWriter
java.lang.Object
org.locationtech.jtstest.util.io.SVGWriter
Writes the Well-Known Text representation of a
for a formal specification of the format syntax.
Geometry
.
The Well-Known Text format is defined in the
OGC
Simple Features Specification for SQL.
See
invalid reference
WKTReader
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.
- Version:
- 1.7
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private DecimalFormat
private static final int
private String
private boolean
private int
private int
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendCoordinate
(Coordinate coordinate, Writer writer) Converts aCoordinate
to<Point>
format, then appends it to the writer.private void
appendCoordinate
(CoordinateSequence seq, int i, Writer writer) Appends the i'th coordinate from the sequence to the writerprivate void
appendGeometryCollectionTaggedText
(GeometryCollection geometryCollection, int level, Writer writer) Converts aGeometryCollection
to <GeometryCollection Tagged Text> format, then appends it to the writer.private void
appendGeometryCollectionText
(GeometryCollection geometryCollection, int level, Writer writer) Converts aGeometryCollection
to <GeometryCollectionText> format, then appends it to the writer.private void
appendGeometryTaggedText
(Geometry geometry, int level, Writer writer) Converts aGeometry
to <Geometry Tagged Text> format, then appends it to the writer.private void
appendLinearRingTaggedText
(LinearRing linearRing, int level, Writer writer) Converts aLinearRing
to <LinearRing Tagged Text> format, then appends it to the writer.private void
appendLineString
(LineString lineString, int level, boolean doIndent, Writer writer) Converts aLineString
to <LineString Text> format, then appends it to the writer.private void
appendLineStringTaggedText
(LineString lineString, int level, Writer writer) Converts aLineString
to <LineString Tagged Text> format, then appends it to the writer.private void
appendMultiLineStringTaggedText
(MultiLineString multiLineString, int level, Writer writer) Converts aMultiLineString
to <MultiLineString Tagged Text> format, then appends it to the writer.private void
appendMultiLineStringText
(MultiLineString multiLineString, int level, boolean indentFirst, Writer writer) Converts aMultiLineString
to <MultiLineString Text> format, then appends it to the writer.private void
appendMultiPointTaggedText
(MultiPoint multipoint, int level, Writer writer) Converts aMultiPoint
to <MultiPoint Tagged Text> format, then appends it to the writer.private void
appendMultiPointText
(MultiPoint multiPoint, int level, Writer writer) Converts aMultiPoint
to <MultiPoint Text> format, then appends it to the writer.private void
appendMultiPolygonTaggedText
(MultiPolygon multiPolygon, int level, Writer writer) Converts aMultiPolygon
to <MultiPolygon Tagged Text> format, then appends it to the writer.private void
appendMultiPolygonText
(MultiPolygon multiPolygon, int level, Writer writer) Converts aMultiPolygon
to <MultiPolygon Text> format, then appends it to the writer.private void
appendPathEnd
(Writer writer) private void
appendPathStart
(boolean useFillRule, Writer writer) private void
appendPoint
(Coordinate coordinate, int level, Writer writer, PrecisionModel precisionModel) Converts aCoordinate
to <Point Text> format, then appends it to the writer.private void
appendPointTaggedText
(Coordinate coordinate, int level, Writer writer, PrecisionModel precisionModel) Converts aCoordinate
to <Point Tagged Text> format, then appends it to the writer.private void
appendPolygon
(Polygon polygon, int level, Writer writer) Converts aPolygon
to <Polygon Tagged Text> format, then appends it to the writer.private void
appendPolygonPath
(Polygon polygon, int level, boolean indentFirst, Writer writer) private void
appendPolygonPolygon
(Polygon polygon, int level, boolean indentFirst, Writer writer) Converts aPolygon
to <Polygon Text> format, then appends it to the writer.private void
appendSequencePath
(CoordinateSequence seq, int level, boolean doIndent, Writer writer) Converts aLineString
to <LineString Text> format, then appends it to the writer.private void
appendSequencePoints
(CoordinateSequence seq, int level, boolean doIndent, Writer writer) private static DecimalFormat
createFormatter
(PrecisionModel precisionModel) Creates theDecimalFormat
used to writedouble
s with a sufficient number of decimal places.private void
private void
indentCoords
(int coordIndex, int level, Writer writer) static String
stringOfChar
(char ch, int count) Returns aString
of repeated characters.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.private void
writeFormatted
(Geometry geometry, boolean useFormatting, Writer writer) Converts aGeometry
to its Well-known Text representation.void
writeFormatted
(Geometry geometry, Writer writer) Same aswrite
, but with newlines and spaces to make the well-known text more readable.private String
writeNumber
(double d) Converts adouble
to aString
, not in scientific notation.
-
Field Details
-
INDENT
private static final int INDENT- See Also:
-
outputDimension
private int outputDimension -
formatter
-
isFormatted
private boolean isFormatted -
useFormatting
private boolean useFormatting -
level
private int level -
coordsPerLine
private int coordsPerLine -
indentTabStr
-
-
Constructor Details
-
SVGWriter
public SVGWriter()Creates a new SVGWriter with default settings
-
-
Method Details
-
createFormatter
Creates theDecimalFormat
used to writedouble
s with a sufficient number of decimal places.- Parameters:
precisionModel
- thePrecisionModel
used to determine the number of decimal places to write.- Returns:
- a
DecimalFormat
that writedouble
s without scientific notation.
-
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
-
write
Converts aGeometry
to its Well-known Text representation.- Parameters:
geometry
- aGeometry
to process- Returns:
- a
string (see the OpenGIS Simple Features Specification)
-
write
Converts aGeometry
to its Well-known Text representation.- Parameters:
geometry
- aGeometry
to process- Throws:
IOException
-
writeFormatted
Same aswrite
, but with newlines and spaces to make the well-known text more readable.- 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.- Parameters:
geometry
- aGeometry
to process- Throws:
IOException
-
writeFormatted
private void writeFormatted(Geometry geometry, boolean useFormatting, Writer writer) throws IOException Converts aGeometry
to its Well-known Text representation.- Parameters:
geometry
- aGeometry
to process- Throws:
IOException
-
appendGeometryTaggedText
private void appendGeometryTaggedText(Geometry geometry, int level, Writer writer) throws IOException Converts aGeometry
to <Geometry Tagged Text> format, then appends it to the writer.- Parameters:
geometry
- theGeometry
to processwriter
- the output writer to append to- Throws:
IOException
-
appendPointTaggedText
private void appendPointTaggedText(Coordinate coordinate, int level, Writer writer, PrecisionModel precisionModel) throws IOException Converts aCoordinate
to <Point Tagged Text> format, then appends it to the writer.- Parameters:
coordinate
- theCoordinate
to processwriter
- the output writer to append toprecisionModel
- thePrecisionModel
to use to convert from a precise coordinate to an external coordinate- Throws:
IOException
-
appendLineStringTaggedText
private void appendLineStringTaggedText(LineString lineString, int level, Writer writer) throws IOException Converts aLineString
to <LineString Tagged Text> format, then appends it to the writer.- Parameters:
lineString
- theLineString
to processwriter
- the output writer to append to- Throws:
IOException
-
appendLinearRingTaggedText
private void appendLinearRingTaggedText(LinearRing linearRing, int level, Writer writer) throws IOException Converts aLinearRing
to <LinearRing Tagged Text> format, then appends it to the writer.- Parameters:
linearRing
- theLinearRing
to processwriter
- the output writer to append to- Throws:
IOException
-
appendPolygon
Converts aPolygon
to <Polygon Tagged Text> format, then appends it to the writer.- Parameters:
polygon
- thePolygon
to processwriter
- the output writer to append to- Throws:
IOException
-
appendMultiPointTaggedText
private void appendMultiPointTaggedText(MultiPoint multipoint, int level, Writer writer) throws IOException Converts aMultiPoint
to <MultiPoint Tagged Text> format, then appends it to the writer.- Parameters:
multipoint
- theMultiPoint
to processwriter
- the output writer to append to- Throws:
IOException
-
appendMultiLineStringTaggedText
private void appendMultiLineStringTaggedText(MultiLineString multiLineString, int level, Writer writer) throws IOException Converts aMultiLineString
to <MultiLineString Tagged Text> format, then appends it to the writer.- Parameters:
multiLineString
- theMultiLineString
to processwriter
- the output writer to append to- Throws:
IOException
-
appendMultiPolygonTaggedText
private void appendMultiPolygonTaggedText(MultiPolygon multiPolygon, int level, Writer writer) throws IOException Converts aMultiPolygon
to <MultiPolygon Tagged Text> format, then appends it to the writer.- Parameters:
multiPolygon
- theMultiPolygon
to processwriter
- the output writer to append to- Throws:
IOException
-
appendGeometryCollectionTaggedText
private void appendGeometryCollectionTaggedText(GeometryCollection geometryCollection, int level, Writer writer) throws IOException Converts aGeometryCollection
to <GeometryCollection Tagged Text> format, then appends it to the writer.- Parameters:
geometryCollection
- theGeometryCollection
to processwriter
- the output writer to append to- Throws:
IOException
-
appendPoint
private void appendPoint(Coordinate coordinate, int level, Writer writer, PrecisionModel precisionModel) throws IOException Converts aCoordinate
to <Point Text> format, then appends it to the writer.- Parameters:
coordinate
- theCoordinate
to processwriter
- the output writer to append toprecisionModel
- thePrecisionModel
to use to convert from a precise coordinate to an external coordinate- Throws:
IOException
-
appendCoordinate
Appends the i'th coordinate from the sequence to the writer- Parameters:
seq
- theCoordinateSequence
to processi
- the index of the coordinate to writewriter
- the output writer to append to- Throws:
IOException
-
appendCoordinate
Converts aCoordinate
to<Point>
format, then appends it to the writer.- Parameters:
coordinate
- theCoordinate
to processwriter
- the output writer to append to- Throws:
IOException
-
writeNumber
Converts adouble
to aString
, not in scientific notation.- Parameters:
d
- thedouble
to convert- Returns:
- the
double
as aString
, not in scientific notation
-
appendSequencePath
private void appendSequencePath(CoordinateSequence seq, int level, boolean doIndent, Writer writer) throws IOException Converts aLineString
to <LineString Text> format, then appends it to the writer.- Parameters:
writer
- the output writer to append tolineString
- theLineString
to process- Throws:
IOException
-
appendSequencePoints
private void appendSequencePoints(CoordinateSequence seq, int level, boolean doIndent, Writer writer) throws IOException - Throws:
IOException
-
appendLineString
private void appendLineString(LineString lineString, int level, boolean doIndent, Writer writer) throws IOException Converts aLineString
to <LineString Text> format, then appends it to the writer.- Parameters:
lineString
- theLineString
to processwriter
- the output writer to append to- Throws:
IOException
-
appendPolygonPolygon
private void appendPolygonPolygon(Polygon polygon, int level, boolean indentFirst, Writer writer) throws IOException Converts aPolygon
to <Polygon Text> format, then appends it to the writer.- Parameters:
polygon
- thePolygon
to processwriter
- the output writer to append to- Throws:
IOException
-
appendPolygonPath
private void appendPolygonPath(Polygon polygon, int level, boolean indentFirst, Writer writer) throws IOException - Throws:
IOException
-
appendPathStart
- Throws:
IOException
-
appendPathEnd
- Throws:
IOException
-
appendMultiPointText
private void appendMultiPointText(MultiPoint multiPoint, int level, Writer writer) throws IOException Converts aMultiPoint
to <MultiPoint Text> format, then appends it to the writer.- Parameters:
multiPoint
- theMultiPoint
to processwriter
- the output writer to append to- Throws:
IOException
-
appendMultiLineStringText
private void appendMultiLineStringText(MultiLineString multiLineString, int level, boolean indentFirst, Writer writer) throws IOException Converts aMultiLineString
to <MultiLineString Text> format, then appends it to the writer.- Parameters:
multiLineString
- theMultiLineString
to processwriter
- the output writer to append to- Throws:
IOException
-
appendMultiPolygonText
private void appendMultiPolygonText(MultiPolygon multiPolygon, int level, Writer writer) throws IOException Converts aMultiPolygon
to <MultiPolygon Text> format, then appends it to the writer.- Parameters:
multiPolygon
- theMultiPolygon
to processwriter
- the output writer to append to- Throws:
IOException
-
appendGeometryCollectionText
private void appendGeometryCollectionText(GeometryCollection geometryCollection, int level, Writer writer) throws IOException Converts aGeometryCollection
to <GeometryCollectionText> format, then appends it to the writer.- Parameters:
geometryCollection
- theGeometryCollection
to processwriter
- the output writer to append to- Throws:
IOException
-
indentCoords
- Throws:
IOException
-
indent
- Throws:
IOException
-