Exemple #1
0
bool IGCParser::readCRecord(const char *line, int len)
{
	qreal lat, lon;


	if (len < 18)
		return false;

	if (!readLat(line + 1, lat)) {
		_errorString = "Invalid latitude";
		return false;
	}
	if (!readLon(line + 9, lon)) {
		_errorString = "Invalid longitude";
		return false;
	}

	if (!(lat == 0 && lon == 0)) {
		QByteArray ba(line + 18, len - 19);

		Waypoint w(Coordinates(lon, lat));
		w.setName(QString(ba.trimmed()));
		_routes.last().append(w);
	}

	return true;
}
Exemple #2
0
int Gps::readData()
{

    string data;
    ifstream file ("/dev/ttyO1",ios::in);//"gps3.txt"


    if (file)
    {

      //  while (file.eof() != 1) // until we are not at the end of the file, we read data of each line
       // {

            getline(file,data);
            cout << data<<endl;
            strcpy(rawData,data.c_str()); // convert data string into char*

            if (rawData[18]=='A')   //signal valid
            {
                DataPack dataToSend;
                dataToSend.data[0] = readLat();
                dataToSend.data[1] = readLongi();
                dataToSend.id = GPS_ID;
                cout<<"data send: lat = "<<dataToSend.data[0]<<" long = "<<dataToSend.data[1]<<endl;
                cout<<"notify"<<endl;
                notify(dataToSend);
                dataToSend.id = SPEED_ID;
                dataToSend.data[0] = readVelocity();
                dataToSend.data[1] = 0;
                notify(dataToSend);
            return 1;
            }
            else
            {

                cout<< "fail reading \n"<<endl;
                 //file.close();
        return 0;
            }
       // }


    }

    else
    {
        cout << "fail to open \n";
    }

return 1;
}
Exemple #3
0
bool IGCParser::readBRecord(const char *line, int len)
{
	qreal lat, lon, ele;
	QTime time;


	if (len < 35)
		return false;

	if (!readTimestamp(line + 1, time)) {
		_errorString = "Invalid timestamp";
		return false;
	}

	if (!readLat(line + 7, lat)) {
		_errorString = "Invalid latitude";
		return false;
	}
	if (!readLon(line + 15, lon)) {
		_errorString = "Invalid longitude";
		return false;
	}

	if (!readAltitude(line + 24, ele)) {
		_errorString = "Invalid altitude";
		return false;
	}


	if (time < _time)
		_date = _date.addDays(1);
	_time = time;

	Trackpoint t(Coordinates(lon, lat));
	t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
	t.setElevation(ele);
	_tracks.last().append(t);

	return true;
}