public class KMLUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ATAK_KML_TRACK_EXTENDED_SCHEMA |
static long |
DEFAULT_NETWORKLINK_INTERVAL_SECS |
static java.lang.ThreadLocal<java.text.SimpleDateFormat> |
KMLDateFormatter |
static java.lang.ThreadLocal<java.text.SimpleDateFormat> |
KMLDateTimeFormatter
ISO 8601 Time formatter.
|
static java.lang.ThreadLocal<java.text.SimpleDateFormat> |
KMLDateTimeFormatterMillis |
static long |
MIN_NETWORKLINK_INTERVAL_SECS |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addFeatureToDoc(Kml kml,
Feature feature)
Add the specified feature to kml/document Create document and document feature list if
necessary Fail if kml top level feature is not a document
|
static boolean |
addFeatureToFolder(Folder folder,
Feature feature) |
static java.lang.String |
convertAltitudeMode(AltitudeMode altitudeMode)
Convert altitude mode enum to KML-compatible string
|
static GeoPointMetaData[] |
convertCoordinates(Coordinates coordinates)
Coordinates
|
static java.lang.String |
convertKmlColor(int argb)
KML calls for AABBGGRR (not AARRGGBB)
|
static Coordinate |
convertKmlCoord(GeoPointMetaData point,
boolean excludeAltitude) |
static Coordinate |
convertKmlCoord(GeoPointMetaData point,
boolean excludeAltitude,
double unwrap)
Convert a geopoint with height into a KML Coordinate.
|
static java.lang.String |
convertKmlCoords(GeoPointMetaData[] points,
boolean excludeAltitude,
boolean idlWrap180) |
static java.lang.String |
convertKmlCoords(GeoPointMetaData[] points,
boolean excludeAltitude,
boolean idlWrap180,
double height) |
static Track |
convertKmlCoords(java.util.List<CrumbPoint> crumbs,
boolean clampToGround)
Convert crumbs to KML gx:Track
|
static java.lang.String |
convertKmlTime(java.lang.String stringMillis)
Convert to KML time specification
|
static GeoPointMetaData |
convertPoint(Coordinate coord) |
static java.lang.String |
createCDataList(java.lang.String type,
java.lang.String[] items)
Creates a CDATA section containing a list.
|
static LineString |
createLineString(GeoPointMetaData[] points,
java.lang.String string) |
static LineString |
createLineString(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude) |
static LineString |
createLineString(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180)
Create a LineString
|
static Polygon |
createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id) |
static Polygon |
createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude) |
static Polygon |
createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180)
Create a Polygon element containing an outer LinearRing Automatically closes ring if not
already so
|
static Polygon |
createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180,
double height)
Create a Polygon element containing an outer LinearRing Automatically closes ring if not
already so
|
static <T extends Feature> |
deepFeatures(Feature feature,
FeatureHandler<T> handler,
java.lang.Class<T> clazz)
Get all matching features of the specified type Recurse Document and all Folders Similar to
MapGroup.deepForEachItem pattern If handler returns true for any feature, processing stops.
|
static <T extends Feature> |
deepFeatures(Kml kml,
FeatureHandler<T> handler,
java.lang.Class<T> clazz)
Get all matching features of the specified type Recurse Document and all Folders Similar to
MapGroup.deepForEachItem pattern If handler returns true for any feature, processing stops.
|
static Folder |
exportKMLMapGroup(MapGroup group,
ExportFilters filters) |
static KMZFolder |
exportKMZMapGroup(MapGroup group,
ExportFilters filters) |
static <T> T |
fromString(java.lang.String s,
java.lang.Class clazz)
Supports any class that has SimpleKML annotations
|
static <T extends Geometry> |
getFirstGeometry(Placemark placemark,
java.lang.Class<T> clazz)
Get first geometry of the specified type
|
static <T extends StyleSelector> |
getFirstStyle(Feature feature,
java.lang.Class<T> clazz) |
static <T extends StyleSelector> |
getFirstStyle(Kml kml,
java.lang.Class<T> clazz)
Get first style
|
static <T extends Geometry> |
getGeometries(Placemark placemark,
java.lang.Class<T> clazz)
Get all matching geometries of the specified type Note, we dont currently expect a large
number of geometries for a single Placemark If this proves to be incorrect in the future, we
should look at migrated to an approach similar to deepFeatures() to improve performance
|
static java.io.File |
getKmlFileFromKmzFile(java.io.File kmzFile,
java.io.File tmpDir)
Extract from the KMZ file, the first .kml, and store in temp file
|
static java.lang.String |
getNetworkLinkName(java.lang.String parentName,
NetworkLink link) |
static Style |
getStyle(Kml kml,
Placemark placemark)
Follow styleUrl from top of KML Follow StyleMapping if necessary TODO Support Style or
StyleSelector defined on the Placemark directly rather than referenced by styleUrl
|
static <T extends StyleSelector> |
getStyles(Feature feature,
java.util.List<T> output,
java.lang.Class<T> clazz)
Recursively get styles from document and nested Folders
|
static <T extends StyleSelector> |
getStyles(Kml kml,
java.lang.Class<T> clazz)
Note, we dont currently expect a large number of Styles If this proves to be incorrect in the
future, we should look at migrated to an approach similar to deepFeatures() to improve
performance
|
static java.lang.String |
getURL(Link link) |
static java.lang.String |
hash(Style style)
create a repeatable hash for the specified Style
|
static boolean |
isValid(Track track) |
static int |
parseKMLColor(java.lang.String kmlColor)
Android calls for AARRGGBB (not AABBGGRR)
|
static GeoPointMetaData |
parseKMLCoord(java.lang.String coord) |
static GeoPointMetaData |
parseKMLCoord(java.lang.String coord,
double ce,
double le) |
static java.util.Date |
parseKMLDate(java.lang.String time)
Parse KML Date (with millis)
|
static java.util.List<NetworkLink> |
parseNetworkLinks(java.io.InputStream is,
FeatureHandler<NetworkLink> handler)
Parse a list of network links given an XML input stream
Note: Due to a bug with SimpleKML (ATAK-7343) this is performed with
an XML parser as opposed to their built-in parser
|
static java.lang.String |
toHex(int color)
Convert int to 2 digit hex
|
static java.lang.String |
toString(java.lang.Object o,
Serializer serializer)
Note Serializer is passed in for performance while hundred/thousands of objects may be
serialized in a short period of time (e.g.
|
static void |
write(java.lang.String kml,
java.io.File file)
Write KML to file, if necessary, prepend the XML Prolog
|
public static final long MIN_NETWORKLINK_INTERVAL_SECS
public static final long DEFAULT_NETWORKLINK_INTERVAL_SECS
public static final java.lang.String ATAK_KML_TRACK_EXTENDED_SCHEMA
public static final java.lang.ThreadLocal<java.text.SimpleDateFormat> KMLDateTimeFormatter
public static final java.lang.ThreadLocal<java.text.SimpleDateFormat> KMLDateTimeFormatterMillis
public static final java.lang.ThreadLocal<java.text.SimpleDateFormat> KMLDateFormatter
public static <T extends Feature> void deepFeatures(Kml kml,
FeatureHandler<T> handler,
java.lang.Class<T> clazz)
kml - the kml object to searchclazz - public static <T extends Feature> boolean deepFeatures(Feature feature,
FeatureHandler<T> handler,
java.lang.Class<T> clazz)
feature - the feature to deep searchclazz - public static boolean addFeatureToDoc(Kml kml,
Feature feature)
kml - feature - public static boolean addFeatureToFolder(Folder folder,
Feature feature)
public static java.util.List<NetworkLink> parseNetworkLinks(java.io.InputStream is,
FeatureHandler<NetworkLink> handler)
is - Input streamhandler - Feature handler (null to ignore)public static <T extends Geometry> T getFirstGeometry(Placemark placemark,
java.lang.Class<T> clazz)
placemark - clazz - public static <T extends Geometry> java.util.List<T> getGeometries(Placemark placemark,
java.lang.Class<T> clazz)
placemark - clazz - public static <T extends StyleSelector> T getFirstStyle(Kml kml,
java.lang.Class<T> clazz)
kml - public static <T extends StyleSelector> java.util.List<T> getStyles(Kml kml,
java.lang.Class<T> clazz)
kml - clazz - public static <T extends StyleSelector> void getStyles(Feature feature,
java.util.List<T> output,
java.lang.Class<T> clazz)
feature - output - clazz - public static <T extends StyleSelector> T getFirstStyle(Feature feature,
java.lang.Class<T> clazz)
public static Style getStyle(Kml kml,
Placemark placemark)
kml - placemark - public static java.lang.String convertKmlColor(int argb)
argb - public static java.lang.String toHex(int color)
color - public static int parseKMLColor(java.lang.String kmlColor)
kmlColor - (abgr)public static java.lang.String convertKmlTime(java.lang.String stringMillis)
stringMillis - public static java.util.Date parseKMLDate(java.lang.String time)
time - public static GeoPointMetaData parseKMLCoord(java.lang.String coord)
public static GeoPointMetaData parseKMLCoord(java.lang.String coord,
double ce,
double le)
public static <T> T fromString(java.lang.String s,
java.lang.Class clazz)
s - clazz - public static java.lang.String toString(java.lang.Object o,
Serializer serializer)
o - serializer - public static Polygon createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180)
points - points making up the polygonid - shape id attributeidlWrap180 - True if this polygon crosses the IDL but requires point unwrappingpublic static Polygon createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180,
double height)
points - points making up the polygonid - shape id attributeidlWrap180 - True if this polygon crosses the IDL but requires point unwrappingheight - the height in meters for the Polygon, Double.NaN if no height known.public static Polygon createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude)
public static Polygon createPolygonWithLinearRing(GeoPointMetaData[] points,
java.lang.String id)
public static LineString createLineString(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude,
boolean idlWrap180)
points - points making up the polygonid - shape id attributeidlWrap180 - True if this line crosses the IDL but requires point unwrappingpublic static LineString createLineString(GeoPointMetaData[] points,
java.lang.String id,
boolean excludeAltitude)
public static LineString createLineString(GeoPointMetaData[] points,
java.lang.String string)
public static GeoPointMetaData[] convertCoordinates(Coordinates coordinates)
public static GeoPointMetaData convertPoint(Coordinate coord)
public static java.lang.String convertKmlCoords(GeoPointMetaData[] points,
boolean excludeAltitude,
boolean idlWrap180)
public static java.lang.String convertKmlCoords(GeoPointMetaData[] points,
boolean excludeAltitude,
boolean idlWrap180,
double height)
public static Coordinate convertKmlCoord(GeoPointMetaData point,
boolean excludeAltitude,
double unwrap)
point - the point to use for the latitude, longitude, and altitude.excludeAltitude - the boolean to exclude the altitude from the kml stringunwrap - if the idl wrap is to be appliedpublic static Coordinate convertKmlCoord(GeoPointMetaData point,
boolean excludeAltitude)
public static Track convertKmlCoords(java.util.List<CrumbPoint> crumbs, boolean clampToGround)
crumbs - clampToGround - public static java.lang.String convertAltitudeMode(AltitudeMode altitudeMode)
altitudeMode - Altitude modepublic static java.lang.String createCDataList(java.lang.String type,
java.lang.String[] items)
type - items - public static java.io.File getKmlFileFromKmzFile(java.io.File kmzFile,
java.io.File tmpDir)
throws java.io.IOException
kmzFile - java.io.IOExceptionpublic static java.lang.String getNetworkLinkName(java.lang.String parentName,
NetworkLink link)
public static java.lang.String getURL(Link link)
public static void write(java.lang.String kml,
java.io.File file)
kml - file - java.lang.Exceptionpublic static java.lang.String hash(Style style)
style - public static boolean isValid(Track track)
public static Folder exportKMLMapGroup(MapGroup group, ExportFilters filters) throws FormatNotSupportedException
FormatNotSupportedExceptionpublic static KMZFolder exportKMZMapGroup(MapGroup group, ExportFilters filters) throws FormatNotSupportedException
FormatNotSupportedException