NASA World Wind

gov.nasa.worldwind.ogc.kml.impl
Class KMLExportUtil

java.lang.Object
  extended by gov.nasa.worldwind.ogc.kml.impl.KMLExportUtil

public class KMLExportUtil
extends Object

Collection of utilities methods for generating KML.


Constructor Summary
KMLExportUtil()
           
 
Method Summary
static void exportAttributesAsKML(XMLStreamWriter xmlWriter, String styleType, ShapeAttributes attributes)
          Export ShapeAttributes as KML Pair element in a StyleMap.
static void exportBoundaryAsLinearRing(XMLStreamWriter xmlWriter, Iterable<? extends LatLon> boundary, Double altitude)
          Export the boundary of a polygon as a KML LinearRing.
static void exportDimension(XMLStreamWriter xmlWriter, Size dimension, String tagName)
          Export a Size as a KML element.
static void exportOffset(XMLStreamWriter xmlWriter, Offset offset, String tagName)
          Export an Offset as a KML element.
static String kmlAltitudeMode(int altitudeMode)
          Convert a WorldWind altitude mode to a KML altitude mode.
static String kmlBoolean(boolean value)
          Convert a boolean to binary string "1" or "0".
static String stripHexPrefix(String hexString)
          Strip the "0X" prefix from a hex string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KMLExportUtil

public KMLExportUtil()
Method Detail

exportAttributesAsKML

public static void exportAttributesAsKML(XMLStreamWriter xmlWriter,
                                         String styleType,
                                         ShapeAttributes attributes)
                                  throws XMLStreamException,
                                         IOException
Export ShapeAttributes as KML Pair element in a StyleMap. This method assumes that the StyleMap tag has already been written; it writes the Pair tag.

Parameters:
xmlWriter - Writer to receive the Style element.
styleType - The type of style: normal or highlight. Value should match either KMLConstants.NORMAL or KMLConstants.HIGHLIGHT
attributes - Attributes to export. The method takes no action if this parameter is null.
Throws:
XMLStreamException - if exception occurs writing XML.
IOException - if exception occurs exporting data.

exportBoundaryAsLinearRing

public static void exportBoundaryAsLinearRing(XMLStreamWriter xmlWriter,
                                              Iterable<? extends LatLon> boundary,
                                              Double altitude)
                                       throws XMLStreamException
Export the boundary of a polygon as a KML LinearRing.

Parameters:
xmlWriter - Writer to receive generated XML.
boundary - Boundary to export.
altitude - Altitude of the points in the ring.
Throws:
XMLStreamException - if exception occurs writing XML.

exportDimension

public static void exportDimension(XMLStreamWriter xmlWriter,
                                   Size dimension,
                                   String tagName)
                            throws XMLStreamException
Export a Size as a KML element.

Parameters:
xmlWriter - Writer to receive the Style element.
dimension - The dimension to export. If dimension is null, nothing is written to the stream.
tagName - The name of the KML tag to create.
Throws:
XMLStreamException - if exception occurs writing XML.

exportOffset

public static void exportOffset(XMLStreamWriter xmlWriter,
                                Offset offset,
                                String tagName)
                         throws XMLStreamException
Export an Offset as a KML element.

Parameters:
xmlWriter - Writer to receive the Style element.
offset - The offset to export. If offset is null, nothing is written to the stream.
tagName - The name of the KML tag to create.
Throws:
XMLStreamException - if exception occurs writing XML.

kmlAltitudeMode

public static String kmlAltitudeMode(int altitudeMode)
Convert a WorldWind altitude mode to a KML altitude mode.

Parameters:
altitudeMode - Altitude mode to convert.
Returns:
The KML altitude mode that corresponds to altitudeMode.
Throws:
IllegalArgumentException - If altitudeMode is not a valid WorldWind altitude mode.

kmlBoolean

public static String kmlBoolean(boolean value)
Convert a boolean to binary string "1" or "0".

Parameters:
value - Value to convert.
Returns:
"1" if value is true, otherwise "0".

stripHexPrefix

public static String stripHexPrefix(String hexString)
Strip the "0X" prefix from a hex string.

Parameters:
hexString - String to manipulate.
Returns:
The portion of hexString after the 0X. For example: "0X00FF00" => "00FF00". If the string does not begin with 0X, hexString is returned. The comparison is not case sensitive.

NASA World Wind