int nmea_igen_pos_rmove_loop(nmeaGENERATOR *gen, nmeaINFO *info) { nmeaPOS crd; info->direction += nmea_random(-10, 10); info->speed += nmea_random(-2, 3); if(info->direction < 0) info->direction = 359 + info->direction; if(info->direction > 359) info->direction -= 359; if(info->speed > 40) info->speed = 40; if(info->speed < 1) info->speed = 1; nmea_info2pos(info, &crd); nmea_move_horz(&crd, &crd, info->direction, info->speed / 3600); nmea_pos2info(&crd, info); info->declination = info->direction; return 1; };
void MainWindow::gpsTimer() { if (m_info.speed > 0) { m_lines.last().end(); } double total_distance = 0.0; foreach(TravelLine line, m_lines) { // Get the new position _nmeaPOS startPos; _nmeaPOS endPos; // First get the start position nmea_info2pos(&m_info, &startPos); // Calculate the new position based on the bearing and distance nmea_move_horz(&startPos, &endPos, line.bearing(), line.distance() / 1000.0); // Update the info struct nmea_pos2info(&endPos, &m_info); total_distance += line.distance(); }