]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/KML.py
2 Utility classes for working with the Keyhole Markup Language (KML).
8 class KmlObject(object):
10 The base class of all KML elements, according to the reference:
12 http://code.google.com/apis/kml/documentation/kmlreference.html
14 Every other class in this module should derive from
15 KmlObject. This class provides a default constructor which creates
16 some necessary attributes, and default implementations of to_kml()
19 The to_kml() methods of our subclasses will, in general, generate
20 an opening tag, render themselves (whatever that means), and then
21 generate a closing tag. A call to render() generally returns the
22 element's text, and renders its children recursively.
25 def __init__(self
, initial_text
=''):
27 self
.text
= initial_text
37 for c
in self
.children
:
44 class Color(KmlObject
):
54 class Document(KmlObject
):
56 def __init__(self
, initial_text
=''):
57 super(Document
, self
).__init
__(initial_text
)
62 kml
= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
63 kml
+= "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
68 kml
+= "</Document>\n"
80 for c
in self
.children
:
87 class Description(KmlObject
):
92 kml
+= "</description>\n"
97 class Name(KmlObject
):
107 class Placemark(KmlObject
):
110 kml
= "<Placemark>\n"
112 kml
+= "</Placemark>\n"
117 class PolyStyle(KmlObject
):
120 kml
= "<PolyStyle>\n"
122 kml
+= "</PolyStyle>\n"
127 class Style(KmlObject
):
129 def __init__(self
, initial_text
='', initial_id
=None):
130 super(Style
, self
).__init
__(initial_text
)
137 if (self
.id == None):
140 kml
+= ("<Style id=\"%s\">\n" % self
.id)
149 class StyleUrl(KmlObject
):
154 kml
+= "</styleUrl>\n"
159 class RawText(KmlObject
):