Class KMLWriter

Hierarchy: Object , KMLWriter
public class KMLWriter
Writes a formatted string containing the KML representation of a JTS Geometry. The output is KML fragments which can be substituted wherever the KML Geometry abstract element can be used.

Output elements are indented to provide a nicely-formatted representation. An output line prefix and maximum number of coordinates per line can be specified.

The Z ordinate value output can be forced to be a specific value. The extrude and altitudeMode modes can be set. If set, the corresponding sub-elements will be output.

public KMLWriter()
Creates a new writer.
public static String writeGeometry(Geometry geometry, double z)
Writes a Geometry as KML to a string, using a specified Z value.
Parameters:
geometry - geometry the geometry to write
z - z the Z value to use
Returns:
a string containing the KML geometry representation
public static String writeGeometry(Geometry geometry, double z, int precision, boolean extrude, String altitudeMode)
Writes a Geometry as KML to a string, using a specified Z value, precision, extrude flag, and altitude mode code.
Parameters:
geometry - geometry the geometry to write
z - z the Z value to use
precision - precision the maximum number of decimal places to write
extrude - extrude the extrude flag to write
altitudeMode - altitudeMode the altitude model code to write
Returns:
a string containing the KML geometry representation
public void setLinePrefix(String linePrefix)
Sets a tag string which is prefixed to every emitted text line. This can be used to indent the geometry text in a containing document.
Parameters:
linePrefix - linePrefix the tag string
public void setMaximumCoordinatesPerLine(int maxCoordinatesPerLine)
Sets the maximum number of coordinates to output per line.
Parameters:
maxCoordinatesPerLine - maxCoordinatesPerLine the maximum number of coordinates to output
public void setZ(double zVal)
Sets the Z value to be output for all coordinates. This overrides any Z value present in the Geometry coordinates.
Parameters:
zVal - zVal the Z value to output
public void setExtrude(boolean extrude)
Sets the flag to be output in the extrude element.
Parameters:
extrude - extrude the extrude flag to output
public void setTesselate(boolean tesselate)
Sets the flag to be output in the tesselate element.
Parameters:
tesselate - tesselate the tesselate flag to output
public void setAltitudeMode(String altitudeMode)
Sets the value output in the altitudeMode element.
Parameters:
altitudeMode - altitudeMode string representing the altitude mode
public void setPrecision(int precision)
Sets the maximum number of decimal places to output in ordinate values. Useful for limiting output size.
Parameters:
precision - precision the number of decimal places to output
public String write(Geometry geom)
Writes a Geometry in KML format as a string.
Parameters:
geom - geom the geometry to write
Returns:
a string containing the KML geometry representation
public void write(Geometry geometry, Writer writer)
Writes the KML representation of a Geometry to a Writer.
Parameters:
geometry - geometry the geometry to write
writer - writer the Writer to write to
Throws:
IOException - IOException if an I/O error occurred
public void write(Geometry geometry, StringBuffer buf)
Appends the KML representation of a Geometry to a StringBuffer.
Parameters:
geometry - geometry the geometry to write
buf - buf the buffer to write into