Loading isis/src/base/apps/spiceinit/SpiceClient.cpp +28 −48 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <iostream> #include <sstream> #include <QDataStream> #include <QDebug> #include <QDomElement> #include <QFile> Loading Loading @@ -153,7 +154,10 @@ namespace Isis { * @param reply */ void SpiceClient::replyFinished(QNetworkReply *reply) { p_rawResponse = new QString(QString(reply->readAll())); QByteArray p_rawResponseByteArray = reply->readAll(); //qDebug() << "p_rawResponseByteArray:" << p_rawResponseByteArray; // Decode the response // p_response = new QString(); p_response = new QJsonObject(); Loading @@ -163,14 +167,19 @@ namespace Isis { // QByteArray::fromHex(QByteArray(p_rawResponse->toLatin1())).constData()); // QJsonDocument document; QByteArray decoded = QByteArray::fromHex(QByteArray(p_rawResponse->toLatin1())).constData(); QJsonDocument doc = QJsonDocument::fromJson(decoded); QJsonDocument doc = QJsonDocument::fromJson(p_rawResponseByteArray); *p_response = doc.object(); // QFile finalOutput("output.txt"); // finalOutput.open(QIODevice::WriteOnly); // finalOutput.write( document.toJson() ); // finalOutput.close(); QFile finalOutput("output.txt"); finalOutput.open(QIODevice::WriteOnly); finalOutput.write( doc.toJson() ); finalOutput.close(); // Make sure we can get the log out of it before continuing // applicationLog(); Loading Loading @@ -612,19 +621,6 @@ namespace Isis { PvlObject ob("object"); return ob; // QDomElement root = rootXMLElement(); // QDomElement kernelsLabel = findTag(root, "kernels_label"); // QString kernelsLabels = elementContents(kernelsLabel); // // QString unencoded(QByteArray::fromHex(kernelsLabels.toLatin1()).constData()); // // stringstream pvlStream; // pvlStream << unencoded; // // Pvl labels; // pvlStream >> labels; // // return labels.findObject("NaifKeywords"); } Loading @@ -646,40 +642,24 @@ namespace Isis { Table *SpiceClient::readTable(QString jsonName, QString tableName) { checkErrors(); QString value = p_response->value(jsonName).toVariant().toString(); QString decoded(QByteArray::fromHex(value.toLatin1()).constData()); QString value = p_response->value(jsonName).toString(); QByteArray decoded = QByteArray::fromHex(value.toUtf8().constData()); QDataStream decodedStream; decodedStream << decoded; qDebug() << decoded; QFile finalOutput(tableName + ".txt"); finalOutput.open(QIODevice::WriteOnly); finalOutput.write(decoded.toLatin1()); finalOutput.write(decoded); finalOutput.close(); Table *table = new Table(decoded); Table *table = new Table(tableName,tableName+ ".txt"); return table; // QDomElement root = rootXMLElement(); // QDomElement tablesTag = findTag(root, "tables"); // QDomElement pointingTag = findTag(tablesTag, xmlName); // QString encodedString = elementContents(pointingTag); // QByteArray encodedArray; // for (int i = 0; i < encodedString.size(); i++) { // encodedArray.append(encodedString.data()[i]); // } // // QByteArray unencodedArray(QByteArray::fromHex(encodedArray)); // // stringstream tableStream; // tableStream.write(unencodedArray.data(), unencodedArray.size()); // // Pvl lab; // tableStream >> lab; // // Table *table = new Table(tableName); // table->Read(lab, tableStream); // // return table; } }; isis/src/base/apps/spiceinit/spiceinit.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -575,6 +575,8 @@ void requestSpice(Cube *icube, Pvl &labels, QString missionName) { connectionProgress.CheckStatus(); PvlGroup kernelsGroup = client.kernelsGroup(); // qDebug() << "SHAPOOPY!!!"; PvlGroup logGrp = client.applicationLog(); // PvlObject naifKeywords = client.naifKeywordsObject(); Loading Loading @@ -622,9 +624,9 @@ void requestSpice(Cube *icube, Pvl &labels, QString missionName) { icube->putGroup(kernelsGroup); icube->label()->addObject(naifKeywords); qDebug() << "YAYA! " << pointingTable->Records(); icube->write(*pointingTable); qDebug() << "YAYA!"; icube->write(*positionTable); icube->write(*bodyTable); icube->write(*sunPosTable); Loading isis/src/base/apps/spiceit/spiceit/src/requesthandler.cpp +72 −48 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ #include <QDebug> #include <QJsonDocument> #include <QJsonObject> #include <QJsonValue> #include <QFile> #include <QString> #include <QStringList> Loading Loading @@ -295,32 +296,32 @@ void RequestHandler::service(HttpRequest& request, HttpResponse& response) throw IException(IException::Unknown, "Unable to initialize camera model", _FILEINFO_); } else { qDebug() << "SHAPOOPY!!!!"; spiceResponse =packageKernels("kernels" ); } // remove( inputLabels.expanded().toLatin1() ); //clean up p.EndProcess(); } catch (...) { //qDebug() << "Uncaught exception here."; // We failed at something, delete the temp files... // QString outFile = ui.GetFileName("TO"); QFile pointingFile("kernels.pointing"); if ( pointingFile.exists() ) pointingFile.remove(); //if ( pointingFile.exists() ) pointingFile.remove(); QFile positionFile("kernels.position"); if ( positionFile.exists() ) positionFile.remove(); //if ( positionFile.exists() ) positionFile.remove(); QFile bodyRotFile("kernels.bodyrot"); if ( bodyRotFile.exists() ) bodyRotFile.remove(); //if ( bodyRotFile.exists() ) bodyRotFile.remove(); QFile sunFile("kernels.sun"); if ( sunFile.exists() ) sunFile.remove(); //if ( sunFile.exists() ) sunFile.remove(); throw; } // Return a simple HTML document response.write(spiceResponse,true); Loading @@ -342,7 +343,7 @@ bool tryKernels(Cube &cube, Pvl &lab, Process &p, Pvl origLabels = lab; //origLabels.write("lab.txt"); origLabels.write("lab.txt"); // Add the new kernel files to the existing kernels group PvlKeyword lkKeyword("LeapSecond"); PvlKeyword pckKeyword("TargetAttitudeShape"); Loading Loading @@ -541,9 +542,11 @@ QJsonValue tableToJson(QString file) { QFile tableFile(file); tableFile.open(QIODevice::ReadOnly); QByteArray data = tableFile.readAll(); //xml += QString( data.toHex().constData() ) + "\n"; tableFile.close(); return QJsonValue::fromVariant(data.toHex().constData()); return QJsonValue(data.toHex().constData()); } Loading Loading @@ -606,6 +609,10 @@ QByteArray packageKernels(QString toFile) { QFile::remove(kernLabelsFile); stringstream labelStream; labelStream << kernLabels; QString labelText = QString( QByteArray( labelStream.str().c_str() ).toHex().constData() ); spiceData.insert("Kernels Label", QJsonValue::fromVariant(labelText)); spiceData.insert("Instrument Pointing", tableToJson(toFile + ".pointing")); Loading @@ -613,19 +620,36 @@ QByteArray packageKernels(QString toFile) { spiceData.insert("Body Rotation", tableToJson(toFile + ".bodyrot")); spiceData.insert("Sun Position", tableToJson(toFile + ".sun")); QJsonValue pos = spiceData.value("Sun Position"); QByteArray posArray= QByteArray::fromHex(pos.toString().toUtf8() ); //qDebug() << posArray; QString posString(posArray.constData()); qDebug() <<"Sun Position" <<posString; ///QByteArray pos = QByteArray::fromHex(spiceData.value("Sun Position").toString().constData()).toLocal8Bit(); //qDebug() << QString(QByteArray::fromHex(spiceData.value("Sun Position").toString().constData() ); QJsonDocument doc(spiceData); QByteArray encodedXml( doc.toJson().toHex() ); QByteArray jsonHexedTables( doc.toJson() ); QFile finalOutput("finalOutput.txt"); finalOutput.open(QIODevice::WriteOnly); QByteArray decoded = QByteArray::fromHex(encodedXml); finalOutput.write(decoded.constData()); //QByteArray decoded = QByteArray::fromHex(jsonHexedTables); finalOutput.write(jsonHexedTables.constData()); finalOutput.close(); //qDebug() << "SHAPOOPY!!!!"; //int * sizeOfData; //QFile finalsOutput("toFile.txt"); //finalsOutput.open(QIODevice::WriteOnly); //finalsOutput.write(doc.toJson()); //QString raw(doc.rawData(sizeOfData)); //finalsOutput.write(raw.); //finalsOutput.close(); return encodedXml; return jsonHexedTables; } Loading
isis/src/base/apps/spiceinit/SpiceClient.cpp +28 −48 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <iostream> #include <sstream> #include <QDataStream> #include <QDebug> #include <QDomElement> #include <QFile> Loading Loading @@ -153,7 +154,10 @@ namespace Isis { * @param reply */ void SpiceClient::replyFinished(QNetworkReply *reply) { p_rawResponse = new QString(QString(reply->readAll())); QByteArray p_rawResponseByteArray = reply->readAll(); //qDebug() << "p_rawResponseByteArray:" << p_rawResponseByteArray; // Decode the response // p_response = new QString(); p_response = new QJsonObject(); Loading @@ -163,14 +167,19 @@ namespace Isis { // QByteArray::fromHex(QByteArray(p_rawResponse->toLatin1())).constData()); // QJsonDocument document; QByteArray decoded = QByteArray::fromHex(QByteArray(p_rawResponse->toLatin1())).constData(); QJsonDocument doc = QJsonDocument::fromJson(decoded); QJsonDocument doc = QJsonDocument::fromJson(p_rawResponseByteArray); *p_response = doc.object(); // QFile finalOutput("output.txt"); // finalOutput.open(QIODevice::WriteOnly); // finalOutput.write( document.toJson() ); // finalOutput.close(); QFile finalOutput("output.txt"); finalOutput.open(QIODevice::WriteOnly); finalOutput.write( doc.toJson() ); finalOutput.close(); // Make sure we can get the log out of it before continuing // applicationLog(); Loading Loading @@ -612,19 +621,6 @@ namespace Isis { PvlObject ob("object"); return ob; // QDomElement root = rootXMLElement(); // QDomElement kernelsLabel = findTag(root, "kernels_label"); // QString kernelsLabels = elementContents(kernelsLabel); // // QString unencoded(QByteArray::fromHex(kernelsLabels.toLatin1()).constData()); // // stringstream pvlStream; // pvlStream << unencoded; // // Pvl labels; // pvlStream >> labels; // // return labels.findObject("NaifKeywords"); } Loading @@ -646,40 +642,24 @@ namespace Isis { Table *SpiceClient::readTable(QString jsonName, QString tableName) { checkErrors(); QString value = p_response->value(jsonName).toVariant().toString(); QString decoded(QByteArray::fromHex(value.toLatin1()).constData()); QString value = p_response->value(jsonName).toString(); QByteArray decoded = QByteArray::fromHex(value.toUtf8().constData()); QDataStream decodedStream; decodedStream << decoded; qDebug() << decoded; QFile finalOutput(tableName + ".txt"); finalOutput.open(QIODevice::WriteOnly); finalOutput.write(decoded.toLatin1()); finalOutput.write(decoded); finalOutput.close(); Table *table = new Table(decoded); Table *table = new Table(tableName,tableName+ ".txt"); return table; // QDomElement root = rootXMLElement(); // QDomElement tablesTag = findTag(root, "tables"); // QDomElement pointingTag = findTag(tablesTag, xmlName); // QString encodedString = elementContents(pointingTag); // QByteArray encodedArray; // for (int i = 0; i < encodedString.size(); i++) { // encodedArray.append(encodedString.data()[i]); // } // // QByteArray unencodedArray(QByteArray::fromHex(encodedArray)); // // stringstream tableStream; // tableStream.write(unencodedArray.data(), unencodedArray.size()); // // Pvl lab; // tableStream >> lab; // // Table *table = new Table(tableName); // table->Read(lab, tableStream); // // return table; } };
isis/src/base/apps/spiceinit/spiceinit.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -575,6 +575,8 @@ void requestSpice(Cube *icube, Pvl &labels, QString missionName) { connectionProgress.CheckStatus(); PvlGroup kernelsGroup = client.kernelsGroup(); // qDebug() << "SHAPOOPY!!!"; PvlGroup logGrp = client.applicationLog(); // PvlObject naifKeywords = client.naifKeywordsObject(); Loading Loading @@ -622,9 +624,9 @@ void requestSpice(Cube *icube, Pvl &labels, QString missionName) { icube->putGroup(kernelsGroup); icube->label()->addObject(naifKeywords); qDebug() << "YAYA! " << pointingTable->Records(); icube->write(*pointingTable); qDebug() << "YAYA!"; icube->write(*positionTable); icube->write(*bodyTable); icube->write(*sunPosTable); Loading
isis/src/base/apps/spiceit/spiceit/src/requesthandler.cpp +72 −48 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ #include <QDebug> #include <QJsonDocument> #include <QJsonObject> #include <QJsonValue> #include <QFile> #include <QString> #include <QStringList> Loading Loading @@ -295,32 +296,32 @@ void RequestHandler::service(HttpRequest& request, HttpResponse& response) throw IException(IException::Unknown, "Unable to initialize camera model", _FILEINFO_); } else { qDebug() << "SHAPOOPY!!!!"; spiceResponse =packageKernels("kernels" ); } // remove( inputLabels.expanded().toLatin1() ); //clean up p.EndProcess(); } catch (...) { //qDebug() << "Uncaught exception here."; // We failed at something, delete the temp files... // QString outFile = ui.GetFileName("TO"); QFile pointingFile("kernels.pointing"); if ( pointingFile.exists() ) pointingFile.remove(); //if ( pointingFile.exists() ) pointingFile.remove(); QFile positionFile("kernels.position"); if ( positionFile.exists() ) positionFile.remove(); //if ( positionFile.exists() ) positionFile.remove(); QFile bodyRotFile("kernels.bodyrot"); if ( bodyRotFile.exists() ) bodyRotFile.remove(); //if ( bodyRotFile.exists() ) bodyRotFile.remove(); QFile sunFile("kernels.sun"); if ( sunFile.exists() ) sunFile.remove(); //if ( sunFile.exists() ) sunFile.remove(); throw; } // Return a simple HTML document response.write(spiceResponse,true); Loading @@ -342,7 +343,7 @@ bool tryKernels(Cube &cube, Pvl &lab, Process &p, Pvl origLabels = lab; //origLabels.write("lab.txt"); origLabels.write("lab.txt"); // Add the new kernel files to the existing kernels group PvlKeyword lkKeyword("LeapSecond"); PvlKeyword pckKeyword("TargetAttitudeShape"); Loading Loading @@ -541,9 +542,11 @@ QJsonValue tableToJson(QString file) { QFile tableFile(file); tableFile.open(QIODevice::ReadOnly); QByteArray data = tableFile.readAll(); //xml += QString( data.toHex().constData() ) + "\n"; tableFile.close(); return QJsonValue::fromVariant(data.toHex().constData()); return QJsonValue(data.toHex().constData()); } Loading Loading @@ -606,6 +609,10 @@ QByteArray packageKernels(QString toFile) { QFile::remove(kernLabelsFile); stringstream labelStream; labelStream << kernLabels; QString labelText = QString( QByteArray( labelStream.str().c_str() ).toHex().constData() ); spiceData.insert("Kernels Label", QJsonValue::fromVariant(labelText)); spiceData.insert("Instrument Pointing", tableToJson(toFile + ".pointing")); Loading @@ -613,19 +620,36 @@ QByteArray packageKernels(QString toFile) { spiceData.insert("Body Rotation", tableToJson(toFile + ".bodyrot")); spiceData.insert("Sun Position", tableToJson(toFile + ".sun")); QJsonValue pos = spiceData.value("Sun Position"); QByteArray posArray= QByteArray::fromHex(pos.toString().toUtf8() ); //qDebug() << posArray; QString posString(posArray.constData()); qDebug() <<"Sun Position" <<posString; ///QByteArray pos = QByteArray::fromHex(spiceData.value("Sun Position").toString().constData()).toLocal8Bit(); //qDebug() << QString(QByteArray::fromHex(spiceData.value("Sun Position").toString().constData() ); QJsonDocument doc(spiceData); QByteArray encodedXml( doc.toJson().toHex() ); QByteArray jsonHexedTables( doc.toJson() ); QFile finalOutput("finalOutput.txt"); finalOutput.open(QIODevice::WriteOnly); QByteArray decoded = QByteArray::fromHex(encodedXml); finalOutput.write(decoded.constData()); //QByteArray decoded = QByteArray::fromHex(jsonHexedTables); finalOutput.write(jsonHexedTables.constData()); finalOutput.close(); //qDebug() << "SHAPOOPY!!!!"; //int * sizeOfData; //QFile finalsOutput("toFile.txt"); //finalsOutput.open(QIODevice::WriteOnly); //finalsOutput.write(doc.toJson()); //QString raw(doc.rawData(sizeOfData)); //finalsOutput.write(raw.); //finalsOutput.close(); return encodedXml; return jsonHexedTables; }