Created
December 26, 2014 01:35
-
-
Save gregorthebigmac/8258f4e1c25b3d0f662b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <cstdlib> | |
using namespace std; | |
void loadfile(); | |
void sortGPS(); | |
void store(); | |
string line[20000]; // Yes, I'm using global variables. Deal with it! | |
string lat[3000]; | |
string lon[3000]; | |
string dateTime[3000]; | |
int entries = 0; | |
int main() | |
{ | |
loadfile(); | |
sortGPS(); | |
store(); | |
return 0; | |
} | |
void loadfile() | |
{ | |
ifstream fin("log17o.txt"); | |
int strcount = 0; | |
if(fin.is_open()) | |
{ | |
while(getline(fin,line[strcount])) | |
{ | |
strcount++; | |
//cout << strcount << endl; | |
} | |
//cout << "Number of lines: " << strcount << endl; | |
//system("PAUSE"); | |
} | |
else | |
{ | |
cout << "Unable to open file." << endl; | |
} | |
fin.close(); | |
} | |
void sortGPS() | |
{ | |
int latcount = 0; | |
int loncount = 0; | |
int datecount = 0; | |
int counter = 0; | |
size_t found; | |
while (counter < 20000) | |
{ | |
found = line[counter].find("LAT:"); | |
if (found!=std::string::npos) | |
{ | |
//cout << "Got one!" << endl; | |
lat[latcount] = line[counter]; | |
lon[loncount] = line[counter + 1]; | |
dateTime[datecount] = line[counter - 1]; | |
counter++; | |
datecount++; | |
latcount++; | |
loncount++; | |
} | |
else | |
{ | |
counter++; | |
} | |
} | |
/*cout << "Lat Count = " << latcount << endl; | |
cout << "Lon Count = " << loncount << endl; | |
cout << "Date/Time Count = " << datecount << endl; | |
cout << "Counter = " << counter << endl; | |
system("PAUSE");*/ | |
entries = latcount; | |
} | |
void store() | |
{ | |
ofstream fout ("drone_log17o.csv"); | |
int counter = 0; | |
while (counter < entries) | |
{ | |
if (fout.is_open()) | |
{ | |
fout << dateTime[counter] << ","; | |
fout << lat[counter] << ","; | |
fout << lon[counter] << endl; | |
counter++; | |
} | |
else | |
{ | |
cout << "Unable to open file." << endl; | |
} | |
/*cout << dateTime[counter] << endl; | |
cout << lat[counter] << endl; | |
cout << lon[counter] << endl << endl; | |
system("PAUSE")*/ | |
} | |
fout.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment