NASA World Wind

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

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

public class KMLUtil
extends Object


Field Summary
static String KML_FRACTION
           
static String KML_INSET_PIXELS
           
static String KML_PIXELS
           
 
Constructor Summary
KMLUtil()
           
 
Method Summary
static ShapeAttributes assembleInteriorAttributes(ShapeAttributes attrs, KMLPolyStyle style)
           
static ShapeAttributes assembleLineAttributes(ShapeAttributes attrs, KMLLineStyle style)
           
static List<Position> computeAltitude(Globe globe, List<? extends Position> positions, String altitudeMode)
          Compute the altitude of each position in a list, based on altitude mode.
static Position computeAltitude(Globe globe, Position position, String altitudeMode)
          Create a Position, taking into account an altitude mode.
static int convertAltitudeMode(String altMode, int defaultAltMode)
           
static Sector createSectorFromLatLonBox(KMLAbstractLatLonBoxType box)
          Creates a Sector from a KMLAbstractLatLonBoxType's north, south, east, and west coordinates.
static void getPositions(Globe globe, KMLAbstractGeometry geometry, List<Position> positions)
          Get all of the positions that make up a KMLAbstractGeometry.
static boolean isHighlightStyleState(KMLAbstractSubStyle subStyle)
          Indicate whether a specified sub-style has the "highlight" style-state field.
static String kmlUnitsToWWUnits(String units)
          Translate a KML units string ("pixels", "insetPixels", or "fraction") into the corresponding WW unit constant (AVKey.PIXELS, AVKey.INSET_PIXELS, or AVKey.FRACTION.
static List<LatLon> rotateSector(Globe globe, Sector sector, Angle rotation)
          Rotate the corners of a sector around a normal vector through the sector centroid.
static String wwUnitsToKMLUnits(String units)
          Translate a WorldWind units constant (AVKey.PIXELS, AVKey.INSET_PIXELS, or AVKey.FRACTION to the corresponding KML unit string ("pixels", "insetPixels", or "fraction").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KML_FRACTION

public static final String KML_FRACTION
See Also:
Constant Field Values

KML_INSET_PIXELS

public static final String KML_INSET_PIXELS
See Also:
Constant Field Values

KML_PIXELS

public static final String KML_PIXELS
See Also:
Constant Field Values
Constructor Detail

KMLUtil

public KMLUtil()
Method Detail

assembleInteriorAttributes

public static ShapeAttributes assembleInteriorAttributes(ShapeAttributes attrs,
                                                         KMLPolyStyle style)

assembleLineAttributes

public static ShapeAttributes assembleLineAttributes(ShapeAttributes attrs,
                                                     KMLLineStyle style)

computeAltitude

public static List<Position> computeAltitude(Globe globe,
                                             List<? extends Position> positions,
                                             String altitudeMode)
Compute the altitude of each position in a list, based on altitude mode.

Parameters:
globe - Globe to use to determine altitude above terrain.
positions - Positions to compute altitude for.
altitudeMode - A KML altitude mode string.
Returns:
A new list of positions with altitudes set based on altitudeMode.

computeAltitude

public static Position computeAltitude(Globe globe,
                                       Position position,
                                       String altitudeMode)
Create a Position, taking into account an altitude mode.

Parameters:
globe - Globe to use to determine altitude above terrain.
position - Position to evaluate.
altitudeMode - A KML altitude mode string.
Returns:
New Position.

convertAltitudeMode

public static int convertAltitudeMode(String altMode,
                                      int defaultAltMode)

createSectorFromLatLonBox

public static Sector createSectorFromLatLonBox(KMLAbstractLatLonBoxType box)
Creates a Sector from a KMLAbstractLatLonBoxType's north, south, east, and west coordinates. This returns null if any of these coordinates are unspecified.

Parameters:
box - a box who's coordinates define a Sector.
Returns:
the Sector that bounds the specified box's coordinates.
Throws:
IllegalArgumentException - if the box is null.

getPositions

public static void getPositions(Globe globe,
                                KMLAbstractGeometry geometry,
                                List<Position> positions)
Get all of the positions that make up a KMLAbstractGeometry. If the geometry contains other geometries, this method collects all the points from all of the geometries.

Parameters:
globe - Globe to use to determine altitude above terrain.
geometry - Geometry to collect positions from.
positions - Placemark positions will be added to this list.

isHighlightStyleState

public static boolean isHighlightStyleState(KMLAbstractSubStyle subStyle)
Indicate whether a specified sub-style has the "highlight" style-state field.

Parameters:
subStyle - the sub-style to test. May be null, in which case this method returns false.
Returns:
true if the sub-style has the "highlight" field, otherwise false.

kmlUnitsToWWUnits

public static String kmlUnitsToWWUnits(String units)
Translate a KML units string ("pixels", "insetPixels", or "fraction") into the corresponding WW unit constant (AVKey.PIXELS, AVKey.INSET_PIXELS, or AVKey.FRACTION.

Parameters:
units - KML units to translate.
Returns:
WW units, or null if the argument is not a valid KML unit.

rotateSector

public static List<LatLon> rotateSector(Globe globe,
                                        Sector sector,
                                        Angle rotation)
Rotate the corners of a sector around a normal vector through the sector centroid.

Parameters:
globe - Globe to use to compute rotated positions.
sector - Sector to rotate.
rotation - Rotation angle. Positive angles produce counterclockwise rotation.
Returns:
List of rotated corners.

wwUnitsToKMLUnits

public static String wwUnitsToKMLUnits(String units)
Translate a WorldWind units constant (AVKey.PIXELS, AVKey.INSET_PIXELS, or AVKey.FRACTION to the corresponding KML unit string ("pixels", "insetPixels", or "fraction").

Parameters:
units - World Wind units to translate.
Returns:
KML units, or null if the argument is not a valid WW unit.

NASA World Wind