Class KmlUtil

java.lang.Object
ucar.unidata.data.gis.KmlUtil

public class KmlUtil extends Object
DataSource for Web Map Servers
Version:
$Revision: 1.38 $ $Date: 2007/04/16 20:34:52 $
Author:
IDV development team
  • Field Details

  • Constructor Details

    • KmlUtil

      public KmlUtil()
  • Method Details

    • makeElement

      public static Element makeElement(Element parent, String tag)
      Make a Kml element
      Parameters:
      parent - the parent element
      tag - the tag name
      Returns:
      the Element
    • kml

      public static Element kml(String name)
      Make the kml element
      Parameters:
      name - the name of the element (not used)
      Returns:
      the kml element
    • document

      public static Element document(Element parent, String name)
      Make a KML Document
      Parameters:
      parent - parent Element
      name - the name of the Document
      Returns:
      the Document element
    • document

      public static Element document(Element parent, String name, boolean visible)
      Make a KML Document Element
      Parameters:
      parent - the parent node
      name - the name of the document
      visible - true if visible
      Returns:
      the Document element
    • networkLink

      public static Element networkLink(Element parent, String name, String url)
      Make a NetworkLink element
      Parameters:
      parent - parent node
      name - name of the link
      url - link URL
      Returns:
      the NetworkLink element
    • makeText

      public static Element makeText(Element parent, String tag, String text)
      Make a text node in the parent element
      Parameters:
      parent - the parent
      tag - the tag
      text - the text
      Returns:
      parent with the text element (e.g., text)
    • visible

      public static Element visible(Element parent, boolean visible)
      Set the visibility on an Element
      Parameters:
      parent - the parent element
      visible - true to be visible
      Returns:
      the parent
    • snippet

      public static Element snippet(Element parent, String snippet)
      Make a snippet Element
      Parameters:
      parent - the parent
      snippet - the snippet text
      Returns:
      the parent with the snippet
    • open

      public static Element open(Element parent, boolean open)
      Set the open flag on an elemenet
      Parameters:
      parent - the parent node
      open - true to be open
      Returns:
      the parent node
    • timestamp

      public static Element timestamp(Element parent, Date dttm)
      Make a timestamp from the date
      Parameters:
      parent - the parent node
      dttm - the date
      Returns:
      the timestamp
    • pair

      public static Element pair(Element parent, String key, String styleUrl)
      Make a pair element
      Parameters:
      parent - the parent element
      key - the pair key
      styleUrl - the pair styleUrl
      Returns:
      the Pair element
    • stylemap

      public static Element stylemap(Element parent, String id, String normalStyleUrl, String highlightStyleUrl)
      Create a StyleMap for normal and highlighted styles
      Parameters:
      parent - the parent element
      id - the id of the StyleMap
      normalStyleUrl - the styleUrl of the normal style
      highlightStyleUrl - the styleUrl of the highlighted style
      Returns:
      the StyleMap element
    • styleurl

      public static Element styleurl(Element parent, String url)
      Make a styleUrl element (why isn't the s capitalized?)
      Parameters:
      parent - the parent element
      url - the url
      Returns:
      the styleUrl element
    • style

      public static Element style(Element parent, String id)
      Make a Style element
      Parameters:
      parent - the parent node
      id - the Style id
      Returns:
      the Style element
    • iconstyle

      public static Element iconstyle(Element parent, String id, String url)
      Create an IconStyle element enclosed in a Style element
      Parameters:
      parent - the parent Element
      id - name of the enclosing Style element
      url - the icon URL
      Returns:
      the Style element enclosing the IconStyle element
    • iconstyle

      public static Element iconstyle(Element parent, String id, String url, double scale)
      Create an IconStyle element enclosed in a Style element
      Parameters:
      parent - the parent Element
      id - name of the enclosing Style element
      url - the icon URL
      scale - the size scale (>= 0, 1 = normal size)
      Returns:
      the Style element enclosing the IconStyle element
    • iconstyle

      public static Element iconstyle(Element parent, String id, String url, double scale, Color color)
      Create an IconStyle element enclosed in a Style element
      Parameters:
      parent - the parent Element
      id - name of the enclosing Style element
      url - the icon URL
      scale - the size scale (>= 0, 1 = normal size)
      color - the icon color
      Returns:
      the Style element enclosing the IconStyle element
    • iconstyle

      public static Element iconstyle(Element parent, String url, double scale, Color color)
      Create an IconStyle element
      Parameters:
      parent - the parent (Style) Element
      url - the icon URL
      scale - the size scale (>= 0, 1 = normal size)
      color - the icon color
      Returns:
      the IconStyle element
    • balloonstyle

      public static Element balloonstyle(Element parent, String text, Color bgColor)
      Create a BalloonStyle element
      Parameters:
      parent - parent (Style) element
      text - the balloon text
      bgColor - the background color
      Returns:
      the BalloonStyle element
    • balloonstyle

      public static Element balloonstyle(Element parent, String id, String text, Color bgColor)
      Create a BalloonStyle element wrapped in a Style element
      Parameters:
      parent - parent element
      id - of the enclosing Style element
      text - the balloon text
      bgColor - the background color
      Returns:
      the Style Element with the BalloonStyle element included
    • labelstyle

      public static Element labelstyle(Element parent, String id, Color color, int scale)
      Create a LabelStyle element enclosed in a Style Element
      Parameters:
      parent - The parent for the style
      id - the Style id
      color - the label color
      scale - the label size scale
      Returns:
      the Style Element enclosing the LabelStyle
    • labelstyle

      public static Element labelstyle(Element parent, Color color, int scale)
      Create a LabelStyle element
      Parameters:
      parent - The parent (Style) element
      color - the label color
      scale - the label size scale
      Returns:
      the LabelStyle
    • linestyle

      public static Element linestyle(Element parent, String id, Color color, int width)
      Create a LineStyle element
      Parameters:
      parent - the parent node
      id - the id for the enclosing Style
      color - line color
      width - line width
      Returns:
      the LineStyle Element
    • linestring

      public static Element linestring(Element parent, boolean extrude, boolean tesselate, String coordinates)
      Create a LineString element
      Parameters:
      parent - the parent node
      extrude - true to extrude
      tesselate - true to tesselate
      coordinates - comma separated list of coordinates (lon1,lat1,alt1,lon2,lat2,alt2,....lonN,latN,altN)
      Returns:
      the LineString element
    • linestring

      public static Element linestring(Element parent, boolean extrude, boolean tesselate, float[][] coords)
      Create a LineString element
      Parameters:
      parent - the parent node
      extrude - true to extrude
      tesselate - true to tesselate
      coords - array of coordinates (coords[lon,lat] or coords[lon,lat,alt])
      Returns:
      the LineString element
    • coordinates

      public static Element coordinates(Element parent, String coordinates)
      Make a coordinates element
      Parameters:
      parent - the parent node
      coordinates - the coordinates (comma separated values)
      Returns:
      the coordinates element
    • name

      public static Element name(Element parent, String name)
      Make a name element (wrapped in a CDATA structure)
      Parameters:
      parent - the parent node
      name - the name text
      Returns:
      the name element
    • description

      public static Element description(Element parent, String description)
      Make a description element (wrapped in a CDATA structure)
      Parameters:
      parent - the parent node
      description - the description
      Returns:
      the description element
    • folder

      public static Element folder(Element parent, String name)
      Create a Folder element
      Parameters:
      parent - the parent node
      name - the name of the folder
      Returns:
      the Folder element
    • folder

      public static Element folder(Element parent, String name, boolean visible)
      Create a Folder element
      Parameters:
      parent - the parent node
      name - the name of the folder
      visible - true to be visible. (all children must be not visible if you want the folder turned off)
      Returns:
      the Folder element
    • placemark

      public static Element placemark(Element parent, String name, String description)
      Create a Placemark
      Parameters:
      parent - the parent node
      name - the name of the placemark
      description - the description of the placemark
      Returns:
      the Placemark element
    • point

      public static String point(double lat, double lon, double alt, String style)
      Make a point Element string
      Parameters:
      lat - the point latitude
      lon - the point longitude
      alt - the point altitude
      style - the point style (not used)
      Returns:
      the Point text
    • placemark

      public static Element placemark(Element parent, String name, String description, double lat, double lon, double alt, String styleUrl)
      Make a Placemark element
      Parameters:
      parent - the parent node
      name - the Placemark name
      description - the Placemark description
      lat - the latitude
      lon - the latitude
      alt - the latitude
      styleUrl - the styleUrl
      Returns:
      the Placemark element
    • placemark

      public static Element placemark(Element parent, String name, String description, double lat, double lon, double alt, String[] styleUrls, boolean visible)
      Make a Placemark element
      Parameters:
      parent - the parent node
      name - the Placemark name
      description - the Placemark description
      lat - the latitude
      lon - the latitude
      alt - the latitude
      styleUrls - the array styleUrls
      visible - true for this to be showing
      Returns:
      the Placemark element
    • groundOverlay

      public static Element groundOverlay(Element parent, String name, String description, String url, double north, double south, double east, double west)
      Create a GroundOverlay element
      Parameters:
      parent - the parent node
      name - the name of the GroundOverlay
      description - the description of the GroundOverlay
      url - the URL of the overlay
      north - the north coordinate
      south - the south coordinate
      east - the east coordinate
      west - the west coordinate
      Returns:
      the GroundOverlay
    • groundOverlay

      public static Element groundOverlay(Element parent, String name, String description, String url, double north, double south, double east, double west, boolean visible)
      Create a GroundOverlay element
      Parameters:
      parent - the parent node
      name - the name of the GroundOverlay
      description - the description of the GroundOverlay
      url - the URL of the overlay
      north - the north coordinate
      south - the south coordinate
      east - the east coordinate
      west - the west coordinate
      Returns:
      the GroundOverlay
    • placemark

      public static Element placemark(Element parent, String name, String description, float[][] coords, Color color, int width)
      Make a Placemark with a Linestring
      Parameters:
      parent - the parent node
      name - the name of the Placemark
      description - the description of the Placemark
      coords - the line coordinates
      color - the line color
      width - the line width
      Returns:
      the Placemark
    • parseCoordinates

      public static double[][] parseCoordinates(String coords)
      Parse coordinates
      Parameters:
      coords - the string of space separated coordinates
      Returns:
      the parsed coordinates
    • toBGRHexString

      public static String toBGRHexString(Color c)
      Convert the given color to is string BGR hex representation. KML uses ABGR instead of RGBA
      Parameters:
      c - color
      Returns:
      hex representation (BGR) of the Color's r,g,b values
    • screenoverlay

      public static Element screenoverlay(Element parent, String name, String iconURL, double overlayX, double overlayY, String overlayXunits, String overlayYunits, double screenX, double screenY, String screenXunits, String screenYunits)
      Create a ScreenOverlay Element
      Parameters:
      parent - parent Element
      name - the name of the element
      iconURL - the URL of the icon
      overlayX - x component of a point on the overlay image
      overlayY - y component of a point on the overlay image
      overlayXunits - units of overlayX, can be one of: fraction, pixels, or insetPixels
      overlayYunits - units of overlayY, can be one of: fraction, pixels, or insetPixels
      screenX - x component of a point on the screen
      screenY - y component of a point on the screen
      screenXunits - units of screenX, can be one of: fraction, pixels, or insetPixels
      screenYunits - units of screenY, can be one of: fraction, pixels, or insetPixels
      Returns:
      the ScreenOverlay Element
    • screenoverlay

      public static Element screenoverlay(Element parent, String name, String iconURL, double overlayX, double overlayY, String overlayXunits, String overlayYunits, double screenX, double screenY, String screenXunits, String screenYunits, double sizeX, double sizeY, String sizeXunits, String sizeYunits)
      Create a ScreenOverlay Element
      Parameters:
      parent - parent Element
      name - the name of the element
      iconURL - the URL of the icon
      overlayX - x component of a point on the overlay image
      overlayY - y component of a point on the overlay image
      overlayXunits - units of overlayX, can be one of: fraction, pixels, or insetPixels
      overlayYunits - units of overlayY, can be one of: fraction, pixels, or insetPixels
      screenX - x component of a point on the screen
      screenY - y component of a point on the screen
      screenXunits - units of screenX, can be one of: fraction, pixels, or insetPixels
      screenYunits - units of screenY, can be one of: fraction, pixels, or insetPixels
      sizeX - the x size of the image for the screen overlay, as follows: 1 indicates to use the native dimension, 0 indicates to maintain the aspect ratio, a value of n sets the value of the dimension
      sizeY - the y size of the image for the screen overlay (see sizeX)
      sizeXunits - units of sizeX, fraction or pixels
      sizeYunits - units of sizeY, fraction or pixels
      Returns:
      the ScreenOverlay Element