def to_kml(self):
- return self.render()
+ kml = self.OPEN_TAG
+ kml += self.render()
+ kml += self.CLOSE_TAG + "\n"
+ return kml
def render(self):
- kml = self.OPEN_TAG
- kml += escape(self.text)
+ kml = escape(self.text)
for c in self.children:
kml += c.to_kml()
-
- kml += self.CLOSE_TAG + "\n"
return kml
<Document>"""
CLOSE_TAG = """</Document>
- </kml>"""
+</kml>"""
def __init__(self, initial_text=''):
super(Document, self).__init__(initial_text)
+class Coordinates(KmlObject):
+
+ OPEN_TAG = '<coordinates>'
+ CLOSE_TAG = '</coordinates>'
+
+
class LineString(KmlObject):
OPEN_TAG = '<LineString>'
coords = []
for ls in linestrings:
- c_tag_start = ls.find('<coordinates>')
- c_start = c_tag_start + len('<coordinates>')
- c_end = ls.find('</coordinates>')
+ c_tag_start = ls.find(Coordinates.OPEN_TAG)
+ c_start = c_tag_start + len(Coordinates.OPEN_TAG)
+ c_end = ls.find(Coordinates.CLOSE_TAG)
c = ls[ c_start : c_end ]
coords.append(c)