def receivedNmeaSentence(self, sentence): """ callback method - called from the NmeaBuffer """ #print "GOT ",sentence # update last sentence time - to signal that we're receiving correct data if sentence is not None: self.lastSentenceTime = time.time() if sentence == "GPRMC": if (self.nmeaParser.lat != 0 or self.nmeaParser.lon != 0) and self.gpxDoc: curTime = datetime.datetime.now() trkpt = GpxCreation.createTrkPt(self.gpxDoc, self.nmeaParser, curTime) if self.gpxTrkseg.elementsByTagName("trkpt").count() == 0: #if delay between start of recording and first trk point is too big, #insert arbitary first track point to have a correct recording length #(so that user is able to play all recorded data - video etc.) diff = curTime - self.gpxTrksegStartTime if diff.days * 24 * 3600 + diff.seconds > MAX_TRKSEG_EMPTY_BEGIN_TIME: trkpt_stub = GpxCreation.createTrkPt( self.gpxDoc, self.nmeaParser, self.gpxTrksegStartTime) self.gpxTrkseg.appendChild(trkpt_stub) self.gpxTrkseg.appendChild(trkpt) self.emitNewTrackPoint() if sentence == "PTNTHPR": self.emitNewTrackPoint()
def receivedNmeaSentence(self, sentence): """ callback method - called from the NmeaBuffer """ #print "GOT ",sentence # update last sentence time - to signal that we're receiving correct data if sentence is not None: self.lastSentenceTime = time.time() if sentence=="GPRMC": if (self.nmeaParser.lat!=0 or self.nmeaParser.lon!=0) and self.gpxDoc: curTime=datetime.datetime.now() trkpt=GpxCreation.createTrkPt(self.gpxDoc, self.nmeaParser, curTime) if self.gpxTrkseg.elementsByTagName("trkpt").count()==0: #if delay between start of recording and first trk point is too big, #insert arbitary first track point to have a correct recording length #(so that user is able to play all recorded data - video etc.) diff=curTime-self.gpxTrksegStartTime if diff.days*24*3600+diff.seconds>MAX_TRKSEG_EMPTY_BEGIN_TIME: trkpt_stub=GpxCreation.createTrkPt(self.gpxDoc, self.nmeaParser, self.gpxTrksegStartTime) self.gpxTrkseg.appendChild(trkpt_stub) self.gpxTrkseg.appendChild(trkpt) self.emitNewTrackPoint() if sentence=="PTNTHPR": self.emitNewTrackPoint()
def initializeGpxOutput(self): """Preinitialize gpx output object.""" self.gpxDoc=QDomDocument() if os.path.isfile(self.gpxPath): file=QFile(self.gpxPath) if (file.open(QIODevice.ReadOnly)): self.gpxDoc.setContent(file) file.close() self.gpxRoot=self.gpxDoc.documentElement() trkNodes=self.gpxRoot.elementsByTagName("trk") self.gpxTrk=trkNodes.item(trkNodes.length()-1).toElement() self.gpxTrkseg=self.gpxDoc.createElement("trkseg") self.gpxTrk.appendChild(self.gpxTrkseg) else: (self.gpxDoc,self.gpxTrkseg)=GpxCreation.createDom() self.gpxTrksegStartTime=datetime.datetime.now()
def initializeGpxOutput(self): """Preinitialize gpx output object.""" self.gpxDoc = QDomDocument() if os.path.isfile(self.gpxPath): file = QFile(self.gpxPath) if (file.open(QIODevice.ReadOnly)): self.gpxDoc.setContent(file) file.close() self.gpxRoot = self.gpxDoc.documentElement() trkNodes = self.gpxRoot.elementsByTagName("trk") self.gpxTrk = trkNodes.item(trkNodes.length() - 1).toElement() self.gpxTrkseg = self.gpxDoc.createElement("trkseg") self.gpxTrk.appendChild(self.gpxTrkseg) else: (self.gpxDoc, self.gpxTrkseg) = GpxCreation.createDom() self.gpxTrksegStartTime = datetime.datetime.now()