This is a new file which is the GPS log file that comes off the Phantom, except
ID: 653530 • Letter: T
Question
This is a new file which is the GPS log file that comes off the Phantom, except that I've added the number of waypoints to the top of the file (835).
Store the data for each waypoint in an object on the array and calculate a new lat/lon from a specified lat/lon going a given distance with a given heading. Search the internet to find code to do this.
We are interested in the following fields only:
latitude
longitude
altitude(feet)
speed(mph)
gps
power
pitch
roll
yaw
motor on
Sample file:
834,,,,,,,,,,,,,,,,
latitude,longitude,altitude(feet),ascent(feet),speed(mph),distance(feet),max_altitude(feet),max_ascent(feet),max_speed(mph),max_distance(feet),time(millisecond),gps,power,pitch,roll,yaw,motor on
43.5803455,-116.7406308,-1,-1,0,0,0,0,0,0,17943,10,97,178,180,140,1
43.5803455,-116.7406306,-2,-2,0,0,0,0,0,0,18306,10,97,178,180,140,1
43.5803452,-116.7406306,-1,-1,0,0,0,0,0,0,18583,10,97,178,180,140,1
43.5803448,-116.7406304,-1,-1,0,0,0,0,0,0,18905,9,97,178,180,140,1
43.5803445,-116.7406302,-2,-2,0,0,0,0,0,0,19204,9,97,178,180,140,1
43.5803443,-116.7406302,-2,-2,0.22,0,0,0,0.22,0,19482,9,97,178,180,140,1
43.5803443,-116.74063,-2,-2,0.22,0,0,0,0.22,0,19781,9,97,178,180,140,1
43.5803442,-116.74063,-3,-3,0,0,0,0,0.22,0,20101,8,97,178,180,140,1
43.580344,-116.74063,-4,-4,0,0,0,0,0.22,0,20421,8,97,178,180,140,1
43.5803438,-116.74063,-6,-6,0.22,0,0,0,0.22,0,20682,8,97,178,180,140,1
43.5803437,-116.7406299,-7,-7,0.22,0,0,0,0.22,0,21001,8,97,176,180,140,1
43.5803435,-116.7406298,-8,-8,0.32,0,0,0,0.32,0,21281,8,97,176,181,143,1
43.5803435,-116.7406299,-6,-6,0.95,0,0,0,0.95,0,21583,8,97,180,180,142,1
43.5803445,-116.7406291,4,5,2.04,0,4,5,2.04,0,21943,9,97,181,178,142,1
43.580345,-116.7406299,6,6,3.14,0,6,6,3.14,0,22182,9,97,180,178,143,1
43.5803458,-116.7406299,7,7,3.59,0,7,7,3.59,0,22484,8,97,179,178,144,1
43.5803454,-116.7406301,7,8,3.36,0,7,8,3.59,0,22812,8,97,179,178,145,1
43.5803451,-116.7406299,9,9,3.13,0,9,9,3.59,0,23101,8,97,180,178,144,1
43.5803456,-116.7406294,9,9,2.91,0,9,9,3.59,0,23402,7,97,180,178,144,1
43.5803461,-116.7406289,11,11,2.68,0,11,11,3.59,0,23705,7,97,180,178,144,1
43.5803464,-116.7406287,13,13,2.68,0,13,13,3.59,0,24000,7,97,180,178,145,1
43.5803472,-116.7406285,13,13,2.91,0,13,13,3.59,0,24285,7,97,179,179,146,1
These were the instructions I was given nothing more. I am having trouble reading in this type of file (csv) that has commas separating the waypoints. I also dont know how to only chose the ones I only want and exclude the ones I dont.
Explanation / Answer
You need to extract those commas, to the variable of type char:
std::ifstream f("d:\temp\z.txt")
string s;
double lat, lon, alt, asc, speed, dist, max;
vector<double> lat_vec, lon_vec, asc_vec, speed_vec, dist_vec, max_vec;
char c;
while (!f.eof()) {
f>>s; // get one line
stringstream st(s);
// below, eat first number, then comma, then second number, etc.
if (st>>lat>>c>>lon>>c>>alt>>c>>asc>>c>>speed>>c>>dist>>c>>max) {
lat_vec.push_back(lat); lon_vec.push_back(lon);
asc_vec.push_back(asc); speed_vec.push_back(speed);
dist_vec.push_back(dist); max_vec.push_back(max);
}
}
// if you really need arrays, not vectors
double *dist_ar = new double[dist_vec.size];
for (int i=0;i<dist_vec.size(); i++)
dist_ar[i]=dist_vec[i];
return 0;
need more information .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.