Satellites.cpp   Satellites.cpp 
/* /*
* Copyright (C) 2009 Matthew Gates * Copyright (C) 2009, 2012 Matthew Gates
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
skipping to change at line 41 skipping to change at line 41
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "Satellites.hpp" #include "Satellites.hpp"
#include "Satellite.hpp" #include "Satellite.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include <plugin_config.h>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
#include <QAction> #include <QAction>
#include <QProgressBar> #include <QProgressBar>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QVariantMap> #include <QVariantMap>
skipping to change at line 67 skipping to change at line 65
return new Satellites(); return new Satellites();
} }
StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(Satellites); Q_INIT_RESOURCE(Satellites);
StelPluginInfo info; StelPluginInfo info;
info.id = "Satellites"; info.id = "Satellites";
info.displayedName = q_("Satellites"); info.displayedName = N_("Satellites");
info.authors = "Matthew Gates, Jose Luis Canales"; info.authors = "Matthew Gates, Jose Luis Canales";
info.contact = "http://stellarium.org/"; info.contact = "http://stellarium.org/";
info.description = q_("Prediction of artificial satellite po sitions in Earth orbit based on NORAD TLE data"); info.description = N_("Prediction of artificial satellite po sitions in Earth orbit based on NORAD TLE data");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Satellites, SatellitesStelPluginInterface) Q_EXPORT_PLUGIN2(Satellites, SatellitesStelPluginInterface)
Satellites::Satellites() Satellites::Satellites()
: pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon(NULL), toolbarBut ton(NULL), : pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon(NULL), toolbarBut ton(NULL),
earth(NULL), defaultHintColor(0.0, 0.4, 0.6), defaultOrbitColor(0. 0, 0.3, 0.6), earth(NULL), defaultHintColor(0.0, 0.4, 0.6), defaultOrbitColor(0. 0, 0.3, 0.6),
progressBar(NULL) progressBar(NULL)
{ {
skipping to change at line 94 skipping to change at line 92
void Satellites::deinit() void Satellites::deinit()
{ {
Satellite::hintTexture.clear(); Satellite::hintTexture.clear();
texPointer.clear(); texPointer.clear();
} }
Satellites::~Satellites() Satellites::~Satellites()
{ {
delete configDialog; delete configDialog;
if (pxmapGlow)
delete pxmapGlow;
if (pxmapOnIcon)
delete pxmapOnIcon;
if (pxmapOffIcon)
delete pxmapOffIcon;
} }
void Satellites::init() void Satellites::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
try try
{ {
StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Satellites"); StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Satellites");
skipping to change at line 159 skipping to change at line 164
// A timer for hiding alert messages // A timer for hiding alert messages
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
messageTimer->setSingleShot(true); // recurring check for update messageTimer->setSingleShot(true); // recurring check for update
messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->setInterval(9000); // 6 seconds should be enough time
messageTimer->stop(); messageTimer->stop();
connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() )); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() ));
// If the json file does not already exist, create it from the resou rce in the QT resource // If the json file does not already exist, create it from the resou rce in the QT resource
if(QFileInfo(satellitesJsonPath).exists()) if(QFileInfo(satellitesJsonPath).exists())
{ {
if (getJsonFileVersion() != PLUGIN_VERSION) if (getJsonFileVersion() != SATELLITES_PLUGIN_VERSION)
{ {
displayMessage(q_("The old satellites.json file is n o longer compatible - using default file"), "#bb0000"); displayMessage(q_("The old satellites.json file is n o longer compatible - using default file"), "#bb0000");
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Satellites::init satellites.json does not exist - copying default file to " << satellitesJsonPath; qDebug() << "Satellites::init satellites.json does not exist - copying default file to " << satellitesJsonPath;
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
skipping to change at line 404 skipping to change at line 409
conf->setValue("hint_color", "0.0,0.4,0.6"); conf->setValue("hint_color", "0.0,0.4,0.6");
conf->setValue("hint_font_size", 10); conf->setValue("hint_font_size", 10);
conf->setValue("tle_url0", "http://celestrak.com/NORAD/elements/noaa .txt"); conf->setValue("tle_url0", "http://celestrak.com/NORAD/elements/noaa .txt");
conf->setValue("tle_url1", "http://celestrak.com/NORAD/elements/goes .txt"); conf->setValue("tle_url1", "http://celestrak.com/NORAD/elements/goes .txt");
conf->setValue("tle_url2", "http://celestrak.com/NORAD/elements/gps- ops.txt"); conf->setValue("tle_url2", "http://celestrak.com/NORAD/elements/gps- ops.txt");
conf->setValue("tle_url3", "http://celestrak.com/NORAD/elements/gali leo.txt"); conf->setValue("tle_url3", "http://celestrak.com/NORAD/elements/gali leo.txt");
conf->setValue("tle_url4", "http://celestrak.com/NORAD/elements/visu al.txt"); conf->setValue("tle_url4", "http://celestrak.com/NORAD/elements/visu al.txt");
conf->setValue("tle_url5", "http://celestrak.com/NORAD/elements/amat eur.txt"); conf->setValue("tle_url5", "http://celestrak.com/NORAD/elements/amat eur.txt");
conf->setValue("tle_url6", "http://celestrak.com/NORAD/elements/irid ium.txt"); conf->setValue("tle_url6", "http://celestrak.com/NORAD/elements/irid ium.txt");
conf->setValue("tle_url7", "http://celestrak.com/NORAD/elements/geo. txt"); conf->setValue("tle_url7", "http://celestrak.com/NORAD/elements/geo. txt");
conf->setValue("tle_url8", "http://celestrak.com/NORAD/elements/tle-
new.txt");
conf->setValue("tle_url9", "http://celestrak.com/NORAD/elements/scie
nce.txt");
//TODO: Better? See http://doc.qt.nokia.com/4.7/qsettings.html#begin
WriteArray --BM
conf->setValue("update_frequency_hours", 72); conf->setValue("update_frequency_hours", 72);
conf->setValue("orbit_line_flag", true); conf->setValue("orbit_line_flag", true);
conf->setValue("orbit_line_segments", 90); conf->setValue("orbit_line_segments", 90);
conf->setValue("orbit_fade_segments", 5); conf->setValue("orbit_fade_segments", 5);
conf->setValue("orbit_segment_duration", 20); conf->setValue("orbit_segment_duration", 20);
conf->endGroup(); conf->endGroup();
} }
void Satellites::restoreDefaultJsonFile(void) void Satellites::restoreDefaultJsonFile(void)
{ {
skipping to change at line 603 skipping to change at line 611
defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2]; defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2];
if (map.contains("hintColor")) if (map.contains("hintColor"))
{ {
defaultHintColorMap = map.value("hintColor").toList(); defaultHintColorMap = map.value("hintColor").toList();
defaultHintColor.set(defaultHintColorMap.at(0).toDouble(), d efaultHintColorMap.at(1).toDouble(), defaultHintColorMap.at(2).toDouble()); defaultHintColor.set(defaultHintColorMap.at(0).toDouble(), d efaultHintColorMap.at(1).toDouble(), defaultHintColorMap.at(2).toDouble());
} }
satellites.clear(); satellites.clear();
QVariantMap satMap = map.value("satellites").toMap(); QVariantMap satMap = map.value("satellites").toMap();
foreach(const QString& designation, satMap.keys()) foreach(const QString& satId, satMap.keys())
{ {
QVariantMap satData = satMap.value(designation).toMap(); QVariantMap satData = satMap.value(satId).toMap();
satData["designation"] = designation;
if (!satData.contains("hintColor")) if (!satData.contains("hintColor"))
satData["hintColor"] = defaultHintColorMap; satData["hintColor"] = defaultHintColorMap;
if (!satData.contains("orbitColor")) if (!satData.contains("orbitColor"))
satData["orbitColor"] = satData["hintColor"]; satData["orbitColor"] = satData["hintColor"];
SatelliteP sat(new Satellite(satData)); SatelliteP sat(new Satellite(satId, satData));
if (sat->initialized) if (sat->initialized)
{ {
satellites.append(sat); satellites.append(sat);
numReadOk++; numReadOk++;
} }
} }
} }
QVariantMap Satellites::getTleMap(void) QVariantMap Satellites::getTleMap(void)
{ {
QVariantMap map; QVariantMap map;
QVariantList defHintCol; QVariantList defHintCol;
defHintCol << Satellite::roundToDp(defaultHintColor[0],3) defHintCol << Satellite::roundToDp(defaultHintColor[0],3)
<< Satellite::roundToDp(defaultHintColor[1],3) << Satellite::roundToDp(defaultHintColor[1],3)
<< Satellite::roundToDp(defaultHintColor[2],3); << Satellite::roundToDp(defaultHintColor[2],3);
map["creator"] = QString("Satellites plugin version %1 (updated)").a rg(PLUGIN_VERSION); map["creator"] = QString("Satellites plugin version %1 (updated)").a rg(SATELLITES_PLUGIN_VERSION);
map["hintColor"] = defHintCol; map["hintColor"] = defHintCol;
map["shortName"] = "satellite orbital data"; map["shortName"] = "satellite orbital data";
QVariantMap sats; QVariantMap sats;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
QVariantMap satMap = sat->getMap(); QVariantMap satMap = sat->getMap();
if (satMap["orbitColor"] == satMap["hintColor"]) if (satMap["orbitColor"] == satMap["hintColor"])
satMap.remove("orbitColor"); satMap.remove("orbitColor");
if (satMap["hintColor"].toList() == defHintCol) if (satMap["hintColor"].toList() == defHintCol)
satMap.remove("hintColor"); satMap.remove("hintColor");
if (satMap.contains("designation")) sats[sat->id] = satMap;
satMap.remove("designation");
sats[sat->designation] = satMap;
} }
map["satellites"] = sats; map["satellites"] = sats;
return map; return map;
} }
QStringList Satellites::getGroups(void) const QStringList Satellites::getGroups(void) const
{ {
QStringList groups; QStringList groups;
foreach (const SatelliteP& sat, satellites) foreach (const SatelliteP& sat, satellites)
{ {
skipping to change at line 671 skipping to change at line 675
foreach(const QString& group, sat->groupIDs) foreach(const QString& group, sat->groupIDs)
{ {
if (!groups.contains(group)) if (!groups.contains(group))
groups << group; groups << group;
} }
} }
} }
return groups; return groups;
} }
QStringList Satellites::getSatellites(const QString& group, Visibility vis) QHash<QString,QString> Satellites::getSatellites(const QString& group, Stat us vis)
{ {
QStringList result; QHash<QString,QString> result;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized) if (sat->initialized)
if ((group.isEmpty() || sat->groupIDs.contains(group {
)) && ! result.contains(sat->designation)) if ((group.isEmpty() || sat->groupIDs.contains(group
)) && ! result.contains(sat->id))
{ {
if (vis==Both || (vis==Visible && sat->visib if (vis==Both ||
le) || (vis==NotVisible && !sat->visible)) (vis==Visible && sat->visible) ||
result << sat->designation; (vis==NotVisible && !sat->visible) |
|
(vis==OrbitError && !sat->orbitValid
) ||
(vis==NewlyAdded && sat->isNew()))
result.insert(sat->id, sat->name);
} }
}
} }
return result; return result;
} }
SatelliteP Satellites::getByID(const QString& id) SatelliteP Satellites::getByID(const QString& id)
{ {
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->designation == id) if (sat->initialized && sat->id == id)
return sat; return sat;
} }
return SatelliteP(); return SatelliteP();
} }
QStringList Satellites::getAllIDs()
{
QStringList result;
foreach(const SatelliteP& sat, satellites)
{
if (sat->initialized)
result.append(sat->id);
}
return result;
}
void Satellites::add(const TleDataList& newSatellites)
{
int numAdded = 0;
QVariantList defaultHintColorMap;
defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1]
<< defaultHintColor[2];
foreach (const TleData& tleSet, newSatellites)
{
//TODO: Duplicates check? --BM
if (tleSet.id.isEmpty() ||
tleSet.name.isEmpty() ||
tleSet.first.isEmpty() ||
tleSet.second.isEmpty())
continue;
QVariantMap satProperties;
satProperties.insert("name", tleSet.name);
satProperties.insert("tle1", tleSet.first);
satProperties.insert("tle2", tleSet.second);
satProperties.insert("hintColor", defaultHintColorMap);
//TODO: Decide if newly added satellites are visible by defa
ult --BM
satProperties.insert("visible", true);
satProperties.insert("orbitVisible", false);
SatelliteP sat(new Satellite(tleSet.id, satProperties));
if (sat->initialized)
{
qDebug() << "Satellites: added" << tleSet.id << tleS
et.name;
satellites.append(sat);
sat->setNew();
numAdded++;
}
}
qDebug() << "Satellites: "
<< newSatellites.count() << "satellites proposed for additi
on, "
<< numAdded << " added, "
<< satellites.count() << " total after the operation.";
}
void Satellites::remove(const QStringList& idList)
{
StelObjectMgr* objMgr = GETSTELMODULE(StelObjectMgr);
int numRemoved = 0;
for (int i = 0; i < satellites.size(); i++)
{
const SatelliteP& sat = satellites.at(i);
if (idList.contains(sat->id))
{
QList<StelObjectP> selected = objMgr->getSelectedObj
ect("Satellite");
if (selected.contains(sat.staticCast<StelObject>()))
objMgr->unSelect();
qDebug() << "Satellite removed:" << sat->id << sat->
name;
satellites.removeAt(i);
i--; //Compensate for the change in the array's inde
xing
numRemoved++;
}
}
qDebug() << "Satellites: "
<< idList.count() << "satellites proposed for removal, "
<< numRemoved << " removed, "
<< satellites.count() << " remain.";
}
int Satellites::getSecondsToUpdate(void) int Satellites::getSecondsToUpdate(void)
{ {
QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0); QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0);
return QDateTime::currentDateTime().secsTo(nextUpdate); return QDateTime::currentDateTime().secsTo(nextUpdate);
} }
void Satellites::setTleSources(QStringList tleSources) void Satellites::setTleSources(QStringList tleSources)
{ {
updateUrls = tleSources; updateUrls = tleSources;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
skipping to change at line 870 skipping to change at line 958
} }
} }
void Satellites::saveTleData(QString path) void Satellites::saveTleData(QString path)
{ {
saveTleMap(getTleMap(), path); saveTleMap(getTleMap(), path);
} }
void Satellites::updateFromFiles(QStringList paths, bool deleteFiles) void Satellites::updateFromFiles(QStringList paths, bool deleteFiles)
{ {
// define a map of new TLE data - the key is the satellite designati // Container for the new data.
on TleDataHash newTleSets;
QMap< QString, QPair<QString, QString> > newTLE;
if (progressBar) if (progressBar)
{ {
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setMaximum(paths.size() + 1); progressBar->setMaximum(paths.size() + 1);
progressBar->setFormat("TLE updating %v/%m"); progressBar->setFormat("TLE updating %v/%m");
} }
foreach(const QString& tleFilePath, paths) foreach(const QString& tleFilePath, paths)
{ {
QFile tleFile(tleFilePath); QFile tleFile(tleFilePath);
if (tleFile.open(QIODevice::ReadOnly|QIODevice::Text)) if (tleFile.open(QIODevice::ReadOnly|QIODevice::Text))
{ {
int lineNumber = 0; parseTleFile(tleFile, newTleSets);
QString thisSatId("");
QPair<QString, QString> tleLines;
while (!tleFile.atEnd()) {
QString line = QString(tleFile.readLine()).t
rimmed();
if (line.length() < 65) // this is a new des
ignation
{
if (thisSatId!="" && !tleLines.first
.isEmpty() && !tleLines.second.isEmpty())
{
newTLE[thisSatId] = tleLines
;
}
thisSatId = line;
thisSatId.replace(QRegExp("\\s*\\[([
^\\]])*\\]\\s*$"),""); // remove things in square brackets
tleLines.first = QString();
tleLines.second = QString();
}
else
{
if (QRegExp("^1 .*").exactMatch(line
))
tleLines.first = line;
else if (QRegExp("^2 .*").exactMatch
(line))
tleLines.second = line;
else
qDebug() << "Satellites::upd
ateFromFiles(): unprocessed line " << lineNumber << " in file " << tleFile
Path;
}
}
if (thisSatId!="" && !tleLines.first.isEmpty() && !t
leLines.second.isEmpty())
{
newTLE[thisSatId] = tleLines;
}
tleFile.close(); tleFile.close();
if (deleteFiles) if (deleteFiles)
tleFile.remove(); tleFile.remove();
if (progressBar) if (progressBar)
progressBar->setValue(progressBar->value() + 1); progressBar->setValue(progressBar->value() + 1);
} }
} }
// Right, we should now have a map of all the elements we downloaded . For each satellite // Right, we should now have a map of all the elements we downloaded . For each satellite
// which this module is managing, see if it exists with an updated e lement, and update it if so... // which this module is managing, see if it exists with an updated e lement, and update it if so...
int numUpdated = 0; int numUpdated = 0;
int totalSats = 0; int totalSats = 0;
int numMissing = 0; int numMissing = 0;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
totalSats++; totalSats++;
if (newTLE.contains(sat->designation)) QString id = sat->id;
if (newTleSets.contains(id))
{ {
if ( sat->tleElements.first != newTLE[sat->design TleData newTle = newTleSets.value(id);
ation].first if (sat->tleElements.first != newTle.first ||
|| sat->tleElements.second != newTLE[sat->design sat->tleElements.second != newTle.second ||
ation].second) sat->name != newTle.name)
{ {
// We have updated TLE elements for this sat ellite // We have updated TLE elements for this sat ellite
sat->setNewTleElements(newTLE[sat->designati sat->setNewTleElements(newTle.first, newTle.
on].first, newTLE[sat->designation].second); second);
// Update the name if it has been changed in
the source list
sat->name = newTle.name;
// we reset this to "now" when we started th e update. // we reset this to "now" when we started th e update.
sat->lastUpdated = lastUpdate; sat->lastUpdated = lastUpdate;
numUpdated++; numUpdated++;
} }
} }
else else
{ {
qWarning() << "Satellites: could not update orbital qWarning() << "Satellites: could not update orbital
elements for" << sat->designation <<": no entry found in the source TLE lis elements for"
ts."; << sat->name
<< sat->id
<< ": no entry found in the source TLE li
sts.";
numMissing++; numMissing++;
} }
} }
if (numUpdated>0) if (numUpdated>0)
{ {
saveTleMap(getTleMap()); saveTleMap(getTleMap());
} }
delete progressBar; delete progressBar;
progressBar = NULL; progressBar = NULL;
qDebug() << "Satellites: updated" << numUpdated << "/" << totalSats qDebug() << "Satellites: updated" << numUpdated << "/" << totalSats
<< "satellites. Update URLs contained" << newTLE.size() << "objects. " << "satellites. Update URLs contained" << newTleSets.size( ) << "objects. "
<< "There were" << numMissing << "satellies missing from th e update URLs"; << "There were" << numMissing << "satellies missing from th e update URLs";
if (numUpdated==0) if (numUpdated==0)
updateState = CompleteNoUpdates; updateState = CompleteNoUpdates;
else else
updateState = CompleteUpdates; updateState = CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(tleUpdateComplete(numUpdated, totalSats, numMissing)); emit(tleUpdateComplete(numUpdated, totalSats, numMissing));
} }
void Satellites::parseTleFile(QFile& openFile, TleDataHash& tleList)
{
if (!openFile.isOpen() || !openFile.isReadable())
return;
// Code mostly re-used from updateFromFiles()
int lineNumber = 0;
TleData lastData;
while (!openFile.atEnd())
{
QString line = QString(openFile.readLine()).trimmed();
if (line.length() < 65) // this is title line
{
// New entry in the list, so reset all fields
lastData = TleData();
//TODO: We need to think of some kind of ecaping the
se
//characters in the JSON parser. --BM
line.replace(QRegExp("\\s*\\[([^\\]])*\\]\\s*$"),"")
; // remove things in square brackets
lastData.name = line;
}
else
{
if (QRegExp("^1 .*").exactMatch(line))
lastData.first = line;
else if (QRegExp("^2 .*").exactMatch(line))
{
lastData.second = line;
// The Satellite Catalog Number is the secon
d number
// on the second line.
QString id = line.split(' ').at(1).trimmed()
;
if (id.isEmpty())
continue;
lastData.id = id;
// This is the second line and there will be
no more,
// so if everything is OK, save the elements
.
if (!lastData.name.isEmpty() &&
!lastData.first.isEmpty())
{
//TODO: This overwrites duplicates.
Display warning? --BM
tleList.insert(id, lastData);
}
//TODO: Error warnings? --BM
}
else
qDebug() << "Satellites: unprocessed line "
<< lineNumber << " in file " << openFile.fileName();
}
}
}
void Satellites::update(double deltaTime) void Satellites::update(double deltaTime)
{ {
if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e != earth->getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.)) if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e != earth->getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.))
return; return;
hintFader.update((int)(deltaTime*1000)); hintFader.update((int)(deltaTime*1000));
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
 End of changes. 29 change blocks. 
79 lines changed or deleted 205 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/