Module kml

Tools used in the creation of a kml file from a station database. These functions are used in the script stdb_to_kml.py. In a terminal, type stdb_to_kml.py -h for help on usage.

stdb.kml.createKML(nets=[], netd={}, fileName='stdb.kml', opts=None)

Initializes and creates the kml document.

Parameters
  • nets (List) – List of networks

  • netd (Dict) – Dictionary of network elements

  • filename (str) – File name for output .kml file

  • opts – Options read from command line

stdb.kml.createFolder(kmlDoc, net, stlist, netcolour, opts)

For a kmlDocument and a dictionary of stations for a given network, make a folder element for this network, then create a placemark for every station.

Parameters
  • kmldoc – Object

  • net (str) – Name of network

  • stlist (List) – List of station names

  • netcolour (str) – RGB colour for network code

  • opts – Options read from command line

Returns

folderElement – Instance of Folder

Return type

Folder

stdb.kml.createPlacemark(kmlDoc, stdata=None, netcolor='ffffffff', opts=None)

Creates a placemark in kmlDoc for a given row of a dictionary

Parameters
  • kmldoc – Object

  • stdata (Dict) – Dictionary of station metadata

  • netcolour (str) – RGB colour for network code

  • opts – Options read from command line

Returns

placemarkElement – Instance of Folder

Return type

Folder

stdb.kml.createStyleState(kmlDoc, scale, idtag)

Used to create a doucment wide style state with the LabelStyle internal field scale. Sets the Labelstyle scale field to value “scale” and names the field “idtag”

stdb.kml.createPair(kmlDoc, mode, state)

Used to create a single Pair environment that has a particular mode and state

stdb.kml.createStyleMap(kmlDoc)

Creates a StyleMap environment called on-offText which enables label text for Placemarks on mouseover only.

stdb.kml.createStyle(kmlDoc, netcolor, size, labtype='net', op=0)

Creates a Style Environment with a variable size and colour. The last argument selects between two different icon types.

stdb.kml.createDoc(kmlDoc, name)

Initialize the KML Document using name

stdb.kml.gen_colors(n, norand=False)

Produce n evenly distributed colors using the HSV colour pickle and the golden ratio value of ~0.6 to separate the colours. By default the initial colour selected is random.

stdb.kml.rgb2hex(rgbl)

Return hexidecial XML form of RGB colour tuple. Note that the xml parsing of the tuple reads bgr rather than standard rgb, so the rgb tuple is reversed in order on output to represent the true colour