Class KMLUtils
java.lang.Object
org.deltava.util.XMLUtils
org.deltava.util.KMLUtils
A utility class for performing Google Earth KML operations.
- Since:
- 1.0
- Version:
- 4.2
- Author:
- Luke
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyNamespace(Document doc) Updates the namespace of all elements in a KML document to match the parent namespace.static ElementcreateIcon(int palette, int iconCode) Generates a KML icon element.static DocumentCreates a KML root element with the proper namespace and schema definitions.static ElementcreateLookAt(GeospaceLocation loc, int altitude, int heading, int tilt) Generates a KML LookAt element, relative to an existing element.static voidsetVisibility(Element e, boolean isVisible) Sets the visibility for a particular XML element.Methods inherited from class XMLUtils
addIfPresent, createElement, createElement, createElement, createIfPresent, format, getChildText, hasElement, setChildText, stripInvalidUnicodeModifier and TypeMethodDescriptionstatic booleanaddIfPresent(Element be, Element e) Adds a child XML document element to an existing element, if it is not nullstatic ElementcreateElement(String name, String value) Creates a new XML document element.static ElementcreateElement(String name, String value, boolean asCDATA) Creates a new XML document element.static ElementcreateElement(String name, String subElementName, String value) Creates a new XML document element, with an embedded child element.static ElementcreateIfPresent(String name, String value) Creates a new XML document element if the value is not null or empty.static StringConverts an XML document into text using a specific character set.static StringgetChildText(Element e, String... names) Finds a child element multiple levels down and returns its value.static booleanhasElement(Element e, String name) Returns if an XML element contains a child element with a particular name.static voidsetChildText(Element e, String ceName, String value) Updates a child element's text.static StringRemoves invalid unicode characters from an XML element.
-
Method Details
-
createKMLRoot
Creates a KML root element with the proper namespace and schema definitions.- Returns:
- a KML kml element
-
copyNamespace
Updates the namespace of all elements in a KML document to match the parent namespace. This is a bit of a hack since we should probably set the namespace correctly when we create the document.- Parameters:
doc- the KML document
-
setVisibility
Sets the visibility for a particular XML element.- Parameters:
e- the KML elementisVisible- TRUE if the element is visible, otherwise FALSE
-
createIcon
Generates a KML icon element.- Parameters:
palette- the Google Earth palleteiconCode- the icon code- Returns:
- a KML Icon element
-
createLookAt
Generates a KML LookAt element, relative to an existing element.- Parameters:
loc- the location coordinates of the elementaltitude- the altitude of the viewpointheading- the direction of the eyepointtilt- the view tilt angle- Returns:
- a KML LookAt element
-