Fixes #1869: Google Earth additional fields exported as strings, support for variable number of columns
This commit is contained in:
@@ -184,26 +184,8 @@ void logsDialog::on_mapsButton_clicked() {
|
|||||||
int latcol=0, longcol=0, altcol=0, speedcol=0;
|
int latcol=0, longcol=0, altcol=0, speedcol=0;
|
||||||
int itemSelected=0.;
|
int itemSelected=0.;
|
||||||
bool rangeSelected=false;
|
bool rangeSelected=false;
|
||||||
enum fieldtype {
|
|
||||||
T_F,
|
|
||||||
I_F,
|
|
||||||
F_F,
|
|
||||||
G_F
|
|
||||||
};
|
|
||||||
ui->FieldsTW->setDisabled(true);
|
ui->FieldsTW->setDisabled(true);
|
||||||
ui->logTable->setDisabled(true);
|
ui->logTable->setDisabled(true);
|
||||||
QString fields[]={"SWR","RSSI","A1","A2","GPS Date"\
|
|
||||||
,"GPS Time","Long","Lat","Course","GPS Speed","GPS Alt","Baro Alt"\
|
|
||||||
,"Vertical Speed","Temp1","Temp2","RPM","Fuel","Cell volts","Cell 1"\
|
|
||||||
,"Cell 2","Cell 3","Cell 4","Cell 5","Cell 6","Current","Consumption"\
|
|
||||||
,"Vfas","AccelX","AccelY","AccelZ","Rud","Ele","Thr","Ail"\
|
|
||||||
,"S1","S2","LS","RS","SA","SB","SC","SD","SE","SF","SG","SH"};
|
|
||||||
int fieldstype[]={I_F,I_F,F_F,F_F,T_F\
|
|
||||||
,T_F,G_F,G_F,F_F,G_F,G_F,F_F\
|
|
||||||
,F_F,F_F,F_F,I_F,I_F,F_F,F_F\
|
|
||||||
,F_F,F_F,F_F,F_F,F_F,F_F,F_F\
|
|
||||||
,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\
|
|
||||||
,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F};
|
|
||||||
|
|
||||||
QString gePath=g.gePath();
|
QString gePath=g.gePath();
|
||||||
if (gePath.isEmpty() || !QFile(gePath).exists()) {
|
if (gePath.isEmpty() || !QFile(gePath).exists()) {
|
||||||
@@ -211,19 +193,24 @@ void logsDialog::on_mapsButton_clicked() {
|
|||||||
ui->logTable->setDisabled(false);
|
ui->logTable->setDisabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QSet<int> nondataCols;
|
||||||
for (int i=1; i<csvlog.at(0).count(); i++) {
|
for (int i=1; i<csvlog.at(0).count(); i++) {
|
||||||
//Long,Lat,Course,GPS Speed,GPS Alt
|
//Long,Lat,Course,GPS Speed,GPS Alt
|
||||||
if (csvlog.at(0).at(i).contains("Long")) {
|
if (csvlog.at(0).at(i).contains("Long")) {
|
||||||
longcol=i;
|
longcol=i;
|
||||||
|
nondataCols << i;
|
||||||
}
|
}
|
||||||
if (csvlog.at(0).at(i).contains("Lat")) {
|
if (csvlog.at(0).at(i).contains("Lat")) {
|
||||||
latcol=i;
|
latcol=i;
|
||||||
|
nondataCols << i;
|
||||||
}
|
}
|
||||||
if (csvlog.at(0).at(i).contains("GPS Alt")) {
|
if (csvlog.at(0).at(i).contains("GPS Alt")) {
|
||||||
altcol=i;
|
altcol=i;
|
||||||
|
nondataCols << i;
|
||||||
}
|
}
|
||||||
if (csvlog.at(0).at(i).contains("GPS Speed")) {
|
if (csvlog.at(0).at(i).contains("GPS Speed")) {
|
||||||
speedcol=i;
|
speedcol=i;
|
||||||
|
nondataCols << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (longcol==0 || latcol==0 || altcol==0) {
|
if (longcol==0 || latcol==0 || altcol==0) {
|
||||||
@@ -270,23 +257,15 @@ void logsDialog::on_mapsButton_clicked() {
|
|||||||
outputStream << "\t\t<Style id=\"lineStyle\">\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
|
outputStream << "\t\t<Style id=\"lineStyle\">\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
|
||||||
outputStream << "\t\t<Schema id=\"schema\">\n";
|
outputStream << "\t\t<Schema id=\"schema\">\n";
|
||||||
outputStream << "\t\t\t<gx:SimpleArrayField name=\"GPSSpeed\" type=\"float\">\n\t\t\t\t<displayName>GPS Speed</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
outputStream << "\t\t\t<gx:SimpleArrayField name=\"GPSSpeed\" type=\"float\">\n\t\t\t\t<displayName>GPS Speed</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
||||||
|
// declare additional fields
|
||||||
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
||||||
if (ui->FieldsTW->item(0,i)->isSelected() && fieldstype[i]!=G_F ) {
|
if (ui->FieldsTW->item(0,i)->isSelected() && !nondataCols.contains(i+2)) {
|
||||||
outputStream << "\t\t\t<gx:SimpleArrayField name=\""<< fields[i].replace(" ","_") <<"\" ";
|
QString origName = csvlog.at(0).at(i+2);
|
||||||
switch (fieldstype[i]) {
|
QString safeName = origName;
|
||||||
case T_F:
|
safeName.replace(" ","_");
|
||||||
outputStream << "type=\"string\"";
|
outputStream << "\t\t\t<gx:SimpleArrayField name=\""<< safeName <<"\" ";
|
||||||
break;
|
outputStream << "type=\"string\""; // additional fields have fixed type: string
|
||||||
case I_F:
|
outputStream << ">\n\t\t\t\t<displayName>" << origName << "</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
||||||
outputStream << "type=\"int\"";
|
|
||||||
break;
|
|
||||||
case F_F:
|
|
||||||
outputStream << "type=\"float\"";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
outputStream << ">\n\t\t\t\t<displayName>" << fields[i] << "</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outputStream << "\t\t</Schema>\n";
|
outputStream << "\t\t</Schema>\n";
|
||||||
@@ -335,9 +314,12 @@ void logsDialog::on_mapsButton_clicked() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
outputStream << "\t\t\t\t\t\t\t</gx:SimpleArrayData>\n";
|
outputStream << "\t\t\t\t\t\t\t</gx:SimpleArrayData>\n";
|
||||||
|
// add values for additional fields
|
||||||
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
||||||
if (ui->FieldsTW->item(0,i)->isSelected() && fieldstype[i]!= G_F ) {
|
if (ui->FieldsTW->item(0,i)->isSelected() && !nondataCols.contains(i+2)) {
|
||||||
outputStream << "\t\t\t\t\t\t\t<gx:SimpleArrayData name=\""<< fields[i].replace(" ","_") <<"\">\n";
|
QString safeName = csvlog.at(0).at(i+2);;
|
||||||
|
safeName.replace(" ","_");
|
||||||
|
outputStream << "\t\t\t\t\t\t\t<gx:SimpleArrayData name=\""<< safeName <<"\">\n";
|
||||||
for (int j=1; j<n; j++) {
|
for (int j=1; j<n; j++) {
|
||||||
if ((ui->logTable->item(j-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
if ((ui->logTable->item(j-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||||
outputStream << "\t\t\t\t\t\t\t\t<gx:value>"<< csvlog.at(j).at(i+2) <<"</gx:value>\n";
|
outputStream << "\t\t\t\t\t\t\t\t<gx:value>"<< csvlog.at(j).at(i+2) <<"</gx:value>\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user