public class KMLWriter extends Object
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.
| Modifier and Type | Field and Description |
|---|---|
static String |
ALTITUDE_MODE_ABSOLUTE
The KML standard value
absolute for use in setAltitudeMode(String). |
static String |
ALTITUDE_MODE_CLAMPTOGROUND
The KML standard value
clampToGround for use in setAltitudeMode(String). |
static String |
ALTITUDE_MODE_RELATIVETOGROUND
The KML standard value
relativeToGround for use in setAltitudeMode(String). |
| Constructor and Description |
|---|
KMLWriter()
Creates a new writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
setAltitudeMode(String altitudeMode)
Sets the value output in the
altitudeMode element. |
void |
setExtrude(boolean extrude)
Sets the flag to be output in the
extrude element. |
void |
setLinePrefix(String linePrefix)
Sets a tag string which is prefixed to every emitted text line.
|
void |
setMaximumCoordinatesPerLine(int maxCoordinatesPerLine)
Sets the maximum number of coordinates to output per line.
|
void |
setPrecision(int precision)
Sets the maximum number of decimal places to output in ordinate values.
|
void |
setTesselate(boolean tesselate)
Sets the flag to be output in the
tesselate element. |
void |
setZ(double zVal)
Sets the Z value to be output for all coordinates.
|
String |
write(Geometry geom)
Writes a
Geometry in KML format as a string. |
void |
write(Geometry geometry,
StringBuffer buf)
Appends the KML representation of a
Geometry to a StringBuffer. |
void |
write(Geometry geometry,
Writer writer)
|
static String |
writeGeometry(Geometry geometry,
double z)
Writes a Geometry as KML to a string, using
a specified Z value.
|
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.
|
public static String ALTITUDE_MODE_CLAMPTOGROUND
clampToGround for use in setAltitudeMode(String).public static String ALTITUDE_MODE_RELATIVETOGROUND
relativeToGround for use in setAltitudeMode(String).public static String ALTITUDE_MODE_ABSOLUTE
absolute for use in setAltitudeMode(String).public static String writeGeometry(Geometry geometry, double z)
geometry - the geometry to writez - the Z value to usepublic static String writeGeometry(Geometry geometry, double z, int precision, boolean extrude, String altitudeMode)
geometry - the geometry to writez - the Z value to useprecision - the maximum number of decimal places to writeextrude - the extrude flag to writealtitudeMode - the altitude model code to writepublic void setLinePrefix(String linePrefix)
linePrefix - the tag stringpublic void setMaximumCoordinatesPerLine(int maxCoordinatesPerLine)
maxCoordinatesPerLine - the maximum number of coordinates to outputpublic void setZ(double zVal)
zVal - the Z value to outputpublic void setExtrude(boolean extrude)
extrude element.extrude - the extrude flag to outputpublic void setTesselate(boolean tesselate)
tesselate element.tesselate - the tesselate flag to outputpublic void setAltitudeMode(String altitudeMode)
altitudeMode element.altitudeMode - string representing the altitude modepublic void setPrecision(int precision)
precision - the number of decimal places to outputpublic String write(Geometry geom)
Geometry in KML format as a string.geom - the geometry to writepublic void write(Geometry geometry, Writer writer) throws IOException
geometry - the geometry to writewriter - the Writer to write toIOException - if an I/O error occurredpublic void write(Geometry geometry, StringBuffer buf)
Geometry to a StringBuffer.geometry - the geometry to writebuf - the buffer to write intoCopyright © 2024. All rights reserved.