Beispiel #1
0
QDebug operator<<(QDebug dbg, const QWhereaboutsUpdate &update)
{
    QWhereaboutsCoordinate coord = update.coordinate();
    dbg.nospace() << "QWhereaboutsUpdate("
            << update.updateDateTime().toString("yy/MM/dd hh:mm:ss").toLatin1().constData()
            << " ("
            << coord.latitude()
            << ", " << coord.longitude()
            << ", ";
    if (coord.type() == QWhereaboutsCoordinate::Coordinate3D)
        dbg.nospace() << coord.altitude();
    else
        dbg.nospace() << '?';
    dbg.nospace() << "))";
    return dbg.space();
}
Beispiel #2
0
void TTraceRecorder::addSample(const QWhereaboutsUpdate &update)
{
	if(_firstSample) {
		_firstSample = false;
		_minLat = _maxLat = update.coordinate().latitude();
		_minLon = _maxLon = update.coordinate().longitude();
	} else {
		_minLat = (_minLat < update.coordinate().latitude()) ? _minLat : update.coordinate().latitude();
		_maxLat = (_maxLat > update.coordinate().latitude()) ? _maxLat : update.coordinate().latitude();
		_minLon = (_minLon < update.coordinate().longitude()) ? _minLon : update.coordinate().longitude();
		_maxLon = (_maxLon > update.coordinate().longitude()) ? _maxLon : update.coordinate().longitude();
	}

	if(_trackState == out) {
		QString str = QString("\n  <trk>\n    <name>") + _trackName + QString("</name>\n    <trkseg>\n");
		_tracks->write(str.toAscii());
	} else if(_trackState == onTrack) {
		_tracks->write(QString("    <trkseg>\n").toAscii());
	}
	_trackState = onSeg;

	QString str;
	QString latitude = QString("%1").arg(update.coordinate().latitude(), 0, 'f', 10);
	QString longitude = QString("%1").arg(update.coordinate().longitude(), 0, 'f', 10);
	bool is3d = update.coordinate().type() == QWhereaboutsCoordinate::Coordinate3D;
	QString altitude = (is3d) ? QString::number(update.coordinate().altitude()) : QString("nan");

	while(_pendingWaypoints.count() > 0) {
		str = QString("\n  <wpt lat=\"") + latitude + QString("\" lon=\"") + longitude + QString("\">\n");
		str += QString("    <name>") + _pendingWaypoints.takeFirst() + QString("</name>\n");
		if(is3d) { str += QString("    <ele>") + altitude + QString("</ele>\n"); }
		str += QString("  </wpt>\n");
		_waypoints->write(str.toAscii());
	}

	str = QString("      <trkpt lat=\"") + latitude + QString("\" lon=\"") + longitude + QString("\">\n");
	if(is3d) { str += QString("        <ele>") + altitude + QString("</ele>\n"); }
	str += QString("        <time>") + update.updateDateTime().toString("yyyy-MM-ddThh:mm:ssZ") + QString("</time>\n");
	str += QString("      </trkpt>\n");
	_tracks->write(str.toAscii());

	_samples ++;
	emit signalRecordInfo(_filename, _samples);
}