+ if (recordingStatus == false)
+ {
+ //Get start time and start recording.
+ gpsDateTime->setTime_t(location->getTime());
+ routeStartTime = gpsDateTime->toString("dd.MM.yyyy hh:mm:ss");
+ recordingStatus = true;
+ roundCounter = 0;
+ }
+}
+
+/**
+ *This function stop route recording.
+ *@param QString time recording stop time.
+ */
+void GPSData::stopRouteRecording()
+{
+ if (recordingStatus == true)
+ {
+ //Get stop time and stop recording.
+ gpsDateTime->setTime_t(location->getTime());
+ routeStopTime = gpsDateTime->toString("dd.MM.yyyy hh:mm:ss");
+ recordingStatus = false;
+
+ //Write final xml.
+ QFile file("route.xml");
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+ writeRouteXml(&file, 1);
+ file.close();
+ roundCounter = 0;
+ }
+}
+
+/**
+ *This function write route to .xml file.
+ */
+void GPSData::writeRouteXml(QIODevice *device, int round)
+{
+ xmlwriter.setDevice(device);
+
+ //Write temp xml (routetemp.xml).
+ if ( round == 0 )
+ {
+ xmlwriter.writeStartElement("Point");
+ xmlwriter.writeAttribute("Latitude", QString::number(latitude));
+ xmlwriter.writeAttribute("Longitude", QString::number(longitude));
+ xmlwriter.writeAttribute("Altitude", QString::number(altitude));
+ xmlwriter.writeAttribute("Speed", QString::number(speed));
+ xmlwriter.writeEndElement();//Point
+ }
+
+ //Write final xml (route.xml).
+ else if ( round == 1 )
+ {
+ xmlwriter.writeStartDocument();
+ xmlwriter.writeStartElement("Route");
+ xmlwriter.writeAttribute("Start-time", routeStartTime);
+ xmlwriter.writeAttribute("Stop-time", routeStopTime);
+ xmlwriter.writeAttribute("Points", QString::number(roundCounter));
+
+ //Open temp xml and read points
+ QFile tempFile("routetemp.xml");
+ if (!tempFile.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+ QTextStream readRoute(&tempFile);
+ QTextStream writeRoute(device);
+ writeRoute << readRoute.readLine();
+ tempFile.close();//Close temp xml