Пример #1
0
    def __init__(self,session,filename):
        super(GPXLogger,self).__init__(session)
        self._filename = filename
        #<gpx version="1.1" creator="Lotse"
        #xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        #xmlns="http://www.topografix.com/GPX/1.1"
        #xsi:schemaLocation="http://www.topografix.com/GPS/1/1
        #http://www.topografix.com/GPX/1/1/gpx.xsd">

        self._doc = easyxml.create_doc('gpx')
        gpx_node = self._doc.documentElement
        gpx_node.setAttribute('version','1.1')
        gpx_node.setAttribute('creator','lotse')
        gpx_node.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance')
        gpx_node.setAttribute('xmlns','http://www.topografix.com/GPX/1.1') 
        gpx_node.setAttribute('xsi:schemaLocation',\
        'http://www.topografix.com/GPS/1/1 #http://www.topografix.com/GPX/1/1/gpx.xsd')    

        #<metadata>
        #<name>Lotse</name>
        #<author>Niklas Schnelle</author>
        #<copyright>BSD or GPL v 2.0</copyright>
        #</metadata>
        metadata_node = easyxml.append_element(self._doc,gpx_node,'metadata')
        easyxml.append_element_with_data(self._doc,metadata_node,'name','Lotse')
        easyxml.append_element_with_data(self._doc,metadata_node,'author','Niklas Schnelle')
        easyxml.append_element_with_data(self._doc,metadata_node,'copyright','GPL v 2.0')

        #<trk>
        self._trk_node = easyxml.append_element(self._doc,gpx_node,'trk')
        self._segment_node = None
Пример #2
0
 def save_persistent(self):
     # writexml(self, writer, indent='', addindent='', newl='', encoding=None)
     file = open(os.path.join(self.settingsdir,'persist.xml'), 'w')
     doc = easyxml.create_doc('session')
     root = doc.documentElement
     self._curr_xml_section=None
     #Add WaypointList Section
     waypoint_section=easyxml.append_element(doc,root,'waypoints')
     
     self.wpList.foreach(self.foreach_wpListElement_persist,( doc, waypoint_section ))
    
     doc.writexml(file,' ',' ','\n', 'UTF-8')