Satellite.cpp   Satellite.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "Satellite.hpp" #include "Satellite.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelNavigator.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "gsatellite/gSatTEME.hpp"
#include "gsatellite/gObserver.hpp"
#include "gsatellite/gTime.hpp"
#include "gsatellite/gVector.hpp"
#include <QTextStream> #include <QTextStream>
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
#include <QtOpenGL> #include <QtOpenGL>
#include <QSettings> #include <QSettings>
#include <QByteArray> #include <QByteArray>
#include "gsatellite/gTime.hpp"
#include <cmath> #include <cmath>
// static data members - will be initialised in the Satallites class (the S telObjectMgr) // static data members - will be initialised in the Satallites class (the S telObjectMgr)
StelTextureSP Satellite::hintTexture; StelTextureSP Satellite::hintTexture;
float Satellite::showLabels = true; float Satellite::showLabels = true;
float Satellite::hintBrightness = 0.0; float Satellite::hintBrightness = 0.0;
float Satellite::hintScale = 1.f; float Satellite::hintScale = 1.f;
SphericalCap Satellite::viewportHalfspace = SphericalCap(); SphericalCap Satellite::viewportHalfspace = SphericalCap();
int Satellite::orbitLineSegments = 90; int Satellite::orbitLineSegments = 90;
int Satellite::orbitLineFadeSegments = 4; int Satellite::orbitLineFadeSegments = 4;
int Satellite::orbitLineSegmentDuration = 20; int Satellite::orbitLineSegmentDuration = 20;
bool Satellite::orbitLinesFlag = true; bool Satellite::orbitLinesFlag = true;
Satellite::Satellite(const QVariantMap& map) Satellite::Satellite(const QVariantMap& map)
: initialized(false), visible(true), hintColor(0.0,0.0,0.0), lastUpd ated(), pSatellite(NULL) : initialized(false), visible(true), hintColor(0.0,0.0,0.0), lastUpdated(), pSatWrapper(NULL)
{ {
// return initialized if the mandatory fields are not present // return initialized if the mandatory fields are not present
if (!map.contains("designation") || !map.contains("tle1") || !map.co ntains("tle2")) if (!map.contains("designation") || !map.contains("tle1") || !map.co ntains("tle2"))
return; return;
font.setPixelSize(16); font.setPixelSize(16);
designation = map.value("designation").toString(); designation = map.value("designation").toString();
if (map.contains("description")) description = map.value("descriptio n").toString(); if (map.contains("description")) description = map.value("descriptio n").toString();
if (map.contains("visible")) visible = map.value("visible").toBool() ; if (map.contains("visible")) visible = map.value("visible").toBool() ;
skipping to change at line 109 skipping to change at line 105
orbitColorNight[1] = 0; orbitColorNight[1] = 0;
orbitColorNight[2] = 0; orbitColorNight[2] = 0;
if (StelApp::getInstance().getVisionModeNight()) if (StelApp::getInstance().getVisionModeNight())
orbitColor = &orbitColorNight; orbitColor = &orbitColorNight;
else else
orbitColor = &orbitColorNormal; orbitColor = &orbitColorNormal;
if (map.contains("comms")) if (map.contains("comms"))
{ {
foreach(QVariant comm, map.value("comms").toList()) foreach(const QVariant &comm, map.value("comms").toList())
{ {
QVariantMap commMap = comm.toMap(); QVariantMap commMap = comm.toMap();
commLink c; commLink c;
if (commMap.contains("frequency")) c.frequency = com mMap.value("frequency").toDouble(); if (commMap.contains("frequency")) c.frequency = com mMap.value("frequency").toDouble();
if (commMap.contains("modulation")) c.modulation = c ommMap.value("modulation").toString(); if (commMap.contains("modulation")) c.modulation = c ommMap.value("modulation").toString();
if (commMap.contains("description")) c.description = commMap.value("description").toString(); if (commMap.contains("description")) c.description = commMap.value("description").toString();
comms.append(c); comms.append(c);
} }
} }
if (map.contains("groups")) if (map.contains("groups"))
{ {
foreach(QVariant group, map.value("groups").toList()) foreach(const QVariant &group, map.value("groups").toList() )
{ {
if (!groupIDs.contains(group.toString())) if (!groupIDs.contains(group.toString()))
groupIDs << group.toString(); groupIDs << group.toString();
} }
} }
setNewTleElements(map.value("tle1").toString(), map.value("tle2").to String()); setNewTleElements(map.value("tle1").toString(), map.value("tle2").to String());
if (map.contains("lastUpdated")) if (map.contains("lastUpdated"))
{ {
lastUpdated = map.value("lastUpdated").toDateTime(); lastUpdated = map.value("lastUpdated").toDateTime();
} }
setObserverLocation();
initialized = true; initialized = true;
} }
Satellite::~Satellite() Satellite::~Satellite()
{ {
if(pSatellite != NULL) if (pSatWrapper != NULL)
delete pSatellite; delete pSatWrapper;
} }
double Satellite::roundToDp(float n, int dp) double Satellite::roundToDp(float n, int dp)
{ {
// round n to dp decimal places // round n to dp decimal places
return floor(n * pow(10., dp) + .5) / pow(10., dp); return floor(n * pow(10., dp) + .5) / pow(10., dp);
} }
QVariantMap Satellite::getMap(void) QVariantMap Satellite::getMap(void)
{ {
skipping to change at line 170 skipping to change at line 164
map["description"] = description; map["description"] = description;
map["visible"] = visible; map["visible"] = visible;
map["orbitVisible"] = orbitVisible; map["orbitVisible"] = orbitVisible;
QVariantList col, orbitCol; QVariantList col, orbitCol;
col << roundToDp(hintColor[0],3) << roundToDp(hintColor[1], 3) << ro undToDp(hintColor[2], 3); col << roundToDp(hintColor[0],3) << roundToDp(hintColor[1], 3) << ro undToDp(hintColor[2], 3);
orbitCol << roundToDp(orbitColorNormal[0], 3) << roundToDp(orbitColo rNormal[1], 3) << roundToDp(orbitColorNormal[2],3); orbitCol << roundToDp(orbitColorNormal[0], 3) << roundToDp(orbitColo rNormal[1], 3) << roundToDp(orbitColorNormal[2],3);
map["hintColor"] = col; map["hintColor"] = col;
map["orbitColor"] = orbitCol; map["orbitColor"] = orbitCol;
QVariantList commList; QVariantList commList;
foreach(commLink c, comms) foreach(const commLink &c, comms)
{ {
QVariantMap commMap; QVariantMap commMap;
commMap["frequency"] = c.frequency; commMap["frequency"] = c.frequency;
if (!c.modulation.isEmpty() && c.modulation != "") commMap[" modulation"] = c.modulation; if (!c.modulation.isEmpty() && c.modulation != "") commMap[" modulation"] = c.modulation;
if (!c.description.isEmpty() && c.description != "") commMap ["description"] = c.description; if (!c.description.isEmpty() && c.description != "") commMap ["description"] = c.description;
commList << commMap; commList << commMap;
} }
map["comms"] = commList; map["comms"] = commList;
QVariantList groupList; QVariantList groupList;
foreach(QString g, groupIDs) foreach(const QString &g, groupIDs)
{ {
groupList << g; groupList << g;
} }
map["groups"] = groupList; map["groups"] = groupList;
if (!lastUpdated.isNull()) if (!lastUpdated.isNull())
{ {
map["lastUpdated"] = lastUpdated; map["lastUpdated"] = lastUpdated;
} }
return map; return map;
} }
float Satellite::getSelectPriority(const StelNavigator*) const float Satellite::getSelectPriority(const StelCore*) const
{ {
return -10.; return -10.;
} }
QString Satellite::getInfoString(const StelCore *core, const InfoStringGrou p& flags) const QString Satellite::getInfoString(const StelCore *core, const InfoStringGrou p& flags) const
{ {
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
if (flags&Name) if (flags&Name)
skipping to change at line 220 skipping to change at line 214
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra1)
{ {
oss << "<p>"; oss << "<p>";
oss << QString("Range (km): <b>%1</b>").arg(range, 5, 'f', 2 ) << "<br>"; oss << QString("Range (km): <b>%1</b>").arg(range, 5, 'f', 2 ) << "<br>";
oss << QString("Range rate (km/s): <b>%1</b>").arg(rangeRate , 5, 'f', 3) << "<br>"; oss << QString("Range rate (km/s): <b>%1</b>").arg(rangeRate , 5, 'f', 3) << "<br>";
oss << QString("Altitude (km): <b>%1</b>").arg(height, 5, 'f ', 2) << "<br>"; oss << QString("Altitude (km): <b>%1</b>").arg(height, 5, 'f ', 2) << "<br>";
oss << QString("SubPoint Lat/Long(Deg): <b>%1</b>").arg(LatL oss << QString("SubPoint Lat/Long(Deg): <b>%1</b>").arg(lat
ong[0], 5, 'f', 2) << "/"; LongSubPointPosition[0], 5, 'f', 2) << "/";
oss << QString("<b>%1</b>").arg(LatLong[1], 5, 'f', 3); oss << QString("<b>%1</b>").arg(latLongSubPointPosition[1],
5, 'f', 3);
oss << "</p>"; oss << "</p>";
oss << "TEME Coordinates(km): "; oss << "TEME Coordinates(km): ";
oss << QString("<b>X:</b> %1 ").arg(Position[0], 5, 'f', 2); oss << QString("<b>X:</b> %1 ").arg(position[0], 5, 'f', 2)
oss << QString("<b>Y:</b> %1 ").arg(Position[1], 5, 'f', 2); ;
oss << QString("<b>Z:</b> %1 ").arg(Position[2], 5, 'f', 2) oss << QString("<b>Y:</b> %1 ").arg(position[1], 5, 'f', 2)
<< "<br>"; ;
oss << QString("<b>Z:</b> %1 ").arg(position[2], 5, 'f', 2)
<< "<br>";
oss << "TEME Vel(km/s): "; oss << "TEME Vel(km/s): ";
oss << QString("<b>X:</b> %1 ").arg(Vel[0], 5, 'f', 2); oss << QString("<b>X:</b> %1 ").arg(velocity[0], 5, 'f', 2)
oss << QString("<b>Y:</b> %1 ").arg(Vel[1], 5, 'f', 2); ;
oss << QString("<b>Z:</b> %1 ").arg(Vel[2], 5, 'f', 2) << "< oss << QString("<b>Y:</b> %1 ").arg(velocity[1], 5, 'f', 2)
br>"; ;
oss << QString("<b>Z:</b> %1 ").arg(velocity[2], 5, 'f', 2)
<< "<br>";
oss << "Visibility: ";
switch (visibility)
{
case RADAR_SUN:
oss << "Sat&Observer in Sunlit" << "<br>";
break;
case VISIBLE:
oss << "Visible" << "<br>";
break;
case RADAR_NIGHT:
oss << "Sat. Eclipsed" << "<br>";
break;
case NOT_VISIBLE:
oss << "Sat. Not Visible" << "<br>";
break;
default:
break;
}
} }
if (flags&Extra2 && comms.size() > 0) if (flags&Extra2 && comms.size() > 0)
{ {
foreach (commLink c, comms) foreach(const commLink &c, comms)
{ {
double dop = getDoppler(c.frequency); double dop = getDoppler(c.frequency);
double ddop = dop; double ddop = dop;
char sign; char sign;
if (dop<0.) if (dop<0.)
{ {
sign='-'; sign='-';
ddop*=-1; ddop*=-1;
} }
else else
sign='+'; sign='+';
oss << "<p>"; oss << "<p>";
if (!c.modulation.isEmpty() && c.modulation != "") o ss << " " << c.modulation; if (!c.modulation.isEmpty() && c.modulation != "") o ss << " " << c.modulation;
if (!c.description.isEmpty() && c.description != "") oss << " " << c.description; if (!c.description.isEmpty() && c.description != "") oss << " " << c.description;
if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) oss << "<br>"; if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) oss << "<br>";
oss << QString("%1 MHz (%2%3 kHz)</p>").arg(c.freque ncy, 8, 'f', 5) oss << QString("%1 MHz (%2%3 kHz)</p>").arg(c.freque ncy, 8, 'f', 5)
.arg(sign) .arg(sign)
.arg(ddop, 6, .arg(ddop, 6, 'f', 3);
'f', 3);
} }
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
void Satellite::setObserverLocation(StelLocation* loc) Vec3f Satellite::getInfoColor(void) const
{ {
StelLocation l;
if (loc==NULL)
{
l = StelApp::getInstance().getCore()->getNavigator()->getCur
rentLocation();
}
else
{
l = *loc;
}
observer.setPosition( l.latitude, l.longitude, l.altitude / 1000.0);
}
Vec3f Satellite::getInfoColor(void) const {
return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : hintColor; return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : hintColor;
} }
float Satellite::getVMagnitude(const StelNavigator*) const float Satellite::getVMagnitude(const StelCore*) const
{ {
return 5.0; return 5.0;
} }
double Satellite::getAngularSize(const StelCore*) const double Satellite::getAngularSize(const StelCore*) const
{ {
return 0.00001; return 0.00001;
} }
void Satellite::setNewTleElements(const QString& tle1, const QString& tle2) void Satellite::setNewTleElements(const QString& tle1, const QString& tle2)
{ {
if (pSatellite) if (pSatWrapper)
{ {
gSatTEME *old = pSatellite; gSatWrapper *old = pSatWrapper;
pSatellite = NULL; pSatWrapper = NULL;
delete old; delete old;
} }
tleElements.first.clear(); tleElements.first.clear();
tleElements.first.append(tle1); tleElements.first.append(tle1);
tleElements.second.clear(); tleElements.second.clear();
tleElements.second.append(tle2); tleElements.second.append(tle2);
// The TLE library actually modifies the TLE strings, which is annoy pSatWrapper = new gSatWrapper(designation, tle1, tle2);
ing (because orbitPoints.clear();
// when we get updates, we want to check if there has been a change
by using ==
// with the original. Thus we make a copy to send to the TLE librar
y.
QByteArray t1(tleElements.first), t2(tleElements.second);
// Also, the TLE library expects no more than 130 characters length
input. We
// shouldn't have sane input with a TLE longer than about 80, but ju
st in case
// we have a mal-formed input, we will truncate here to be safe
t1.truncate(130);
t2.truncate(130);
pSatellite = new gSatTEME(designation.toAscii().data(),
t1.data(),
t2.data());
} }
void Satellite::update(double) void Satellite::update(double)
{ {
double jul_utc = StelApp::getInstance().getCore()->getNavigator()->g if (pSatWrapper)
etJDay(); {
epochTime = StelApp::getInstance().getCore()->getJDay();
epochTime = jul_utc; pSatWrapper->setEpoch(epochTime);
position = pSatWrapper->getTEMEPos();
velocity = pSatWrapper->getTEMEVel();
latLongSubPointPosition = pSatWrapper->getSubPoint();
height = latLongSubPointPosition[2];
elAzPosition = pSatWrapper->getAltAz();
elAzPosition.normalize();
if (pSatellite) pSatWrapper->getSlantRange(range, rangeRate);
{ visibility = pSatWrapper->getVisibilityPredict();
pSatellite->setEpoch( epochTime);
Position = pSatellite->getPos();
Vel = pSatellite->getVel();
LatLong = pSatellite->getSubPoint( epochTime);
azElPos = observer.calculateLook( *pSatellite, epochTime);
azimuth = azElPos[ AZIMUTH]/KDEG2RAD;
elevation = azElPos[ ELEVATION]/KDEG2RAD;
range = azElPos[ RANGE];
rangeRate = azElPos[ RANGERATE];
height = LatLong[2];
// Compute orbit points to draw orbit line. // Compute orbit points to draw orbit line.
if(orbitVisible) computeOrbitPoints(); if (orbitVisible) computeOrbitPoints();
} }
} }
double Satellite::getDoppler(double freq) const double Satellite::getDoppler(double freq) const
{ {
double result; double result;
double f = freq * 1000000; double f = freq * 1000000;
result = -f*((rangeRate*1000.0)/SPEED_OF_LIGHT); result = -f*((rangeRate*1000.0)/SPEED_OF_LIGHT);
return result/1000000; return result/1000000;
} }
void Satellite::recalculateOrbitLines(void) void Satellite::recalculateOrbitLines(void)
{ {
orbitPoints.clear(); orbitPoints.clear();
} }
void Satellite::draw(const StelCore* core, StelPainter& painter, float) void Satellite::draw(const StelCore* core, StelPainter& painter, float)
{ {
float a = (azimuth-90)*M_PI/180; XYZ = core->altAzToJ2000(elAzPosition);
Vec3d pos(sin(a),cos(a), tan(elevation * M_PI / 180.));
XYZ = core->getNavigator()->altAzToJ2000(pos);
StelApp::getInstance().getVisionModeNight() ? glColor4f(0.6,0.0,0.0, 1.0) : glColor4f(hintColor[0],hintColor[1],hintColor[2], Satellite::hintBri ghtness); StelApp::getInstance().getVisionModeNight() ? glColor4f(0.6,0.0,0.0, 1.0) : glColor4f(hintColor[0],hintColor[1],hintColor[2], Satellite::hintBri ghtness);
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
Vec3d xy; Vec3d xy;
if (prj->project(XYZ,xy)) if (prj->project(XYZ,xy))
{ {
if (Satellite::showLabels) if (Satellite::showLabels)
{ {
painter.drawText(xy[0], xy[1], designation, 0, 10, 1 0, false); painter.drawText(xy[0], xy[1], designation, 0, 10, 1 0, false);
Satellite::hintTexture->bind(); Satellite::hintTexture->bind();
} }
painter.drawSprite2dMode(xy[0], xy[1], 11); painter.drawSprite2dMode(xy[0], xy[1], 11);
if(orbitVisible && Satellite::orbitLinesFlag) drawOrbit(pain ter); if (orbitVisible && Satellite::orbitLinesFlag) drawOrbit(pai nter);
} }
} }
void Satellite::drawOrbit(StelPainter& painter){ void Satellite::drawOrbit(StelPainter& painter)
{
Vec3d pos,posPrev; Vec3d position,previousPosition;
float a, azimth, elev;
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
QList<gVector>::iterator it= orbitPoints.begin(); QList<Vec3d>::iterator it= orbitPoints.begin();
//First point projection calculation //First point projection calculation
azimth = it->at( AZIMUTH); previousPosition.set(it->operator [](0), it->operator [](1), it->op
elev = it->at( ELEVATION); erator [](2));
a = ( (azimth/KDEG2RAD)-90)*M_PI/180;
posPrev.set(sin(a),cos(a), tan( (elev/KDEG2RAD) * M_PI / 180.));
it++; it++;
StelVertexArray vertexArray; StelVertexArray vertexArray;
vertexArray.primitiveType=StelVertexArray::Lines; vertexArray.primitiveType=StelVertexArray::Lines;
//Rest of points //Rest of points
for(int i=1; i<orbitPoints.size();i++) for (int i=1; i<orbitPoints.size(); i++)
{ {
azimth = it->at( AZIMUTH); position.set(it->operator [](0), it->operator [](1), it->op
elev = it->at( ELEVATION); erator [](2));
a = ( (azimth/KDEG2RAD)-90)*M_PI/180;
pos.set(sin(a),cos(a), tan( (elev/KDEG2RAD) * M_PI / 180.));
it++; it++;
position.normalize();
pos.normalize(); previousPosition.normalize();
posPrev.normalize();
// Draw end (fading) parts of orbit lines one segment at a t ime. // Draw end (fading) parts of orbit lines one segment at a t ime.
if (i<=orbitLineFadeSegments || orbitLineSegments-i < orbitL ineFadeSegments) if (i<=orbitLineFadeSegments || orbitLineSegments-i < orbitL ineFadeSegments)
{ {
painter.setColor((*orbitColor)[0], (*orbitColor)[1], (*orbitColor)[2], hintBrightness * calculateOrbitSegmentIntensity(i)); painter.setColor((*orbitColor)[0], (*orbitColor)[1], (*orbitColor)[2], hintBrightness * calculateOrbitSegmentIntensity(i));
painter.drawGreatCircleArc(posPrev, pos, &viewportHa lfspace); painter.drawGreatCircleArc(previousPosition, positi on, &viewportHalfspace);
} }
else { else
vertexArray.vertex << posPrev << pos; {
vertexArray.vertex << previousPosition << position;
} }
previousPosition = position;
posPrev = pos;
} }
// Draw center section of orbit in one go // Draw center section of orbit in one go
painter.setColor((*orbitColor)[0], (*orbitColor)[1], (*orbitColor)[2 ], hintBrightness); painter.setColor((*orbitColor)[0], (*orbitColor)[1], (*orbitColor)[2 ], hintBrightness);
painter.drawGreatCircleArcs(vertexArray, &viewportHalfspace); painter.drawGreatCircleArcs(vertexArray, &viewportHalfspace);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
float Satellite::calculateOrbitSegmentIntensity(int segNum) float Satellite::calculateOrbitSegmentIntensity(int segNum)
{ {
int endDist = (orbitLineSegments/2) - abs(segNum-1 - (orbitLineSegme nts/2) % orbitLineSegments); int endDist = (orbitLineSegments/2) - abs(segNum-1 - (orbitLineSegme nts/2) % orbitLineSegments);
if (endDist > orbitLineFadeSegments) { return 1.0; } if (endDist > orbitLineFadeSegments)
else { return (endDist + 1) / (orbitLineFadeSegments + 1.0); } {
return 1.0;
}
else
{
return (endDist + 1) / (orbitLineFadeSegments + 1.0);
}
} }
void Satellite::setNightColors(bool night) void Satellite::setNightColors(bool night)
{ {
if (night) if (night)
orbitColor = &orbitColorNight; orbitColor = &orbitColorNight;
else else
orbitColor = &orbitColorNormal; orbitColor = &orbitColorNormal;
} }
void Satellite::computeOrbitPoints() void Satellite::computeOrbitPoints()
{ {
gTimeSpan computeInterval(0, 0, 0, orbitLineSegmentDuration); gTimeSpan computeInterval(0, 0, 0, orbitLineSegmentDuration);
gTimeSpan orbitSpan(0, 0, 0, orbitLineSegments*orbitLineSegmentDurat ion/2); gTimeSpan orbitSpan(0, 0, 0, orbitLineSegments*orbitLineSegmentDurat ion/2);
gTime epochTm; gTime epochTm;
gVector azElVector; gTime epoch(epochTime);
int diffSlots; gTime lastEpochComp(lastEpochCompForOrbit);
Vec3d elAzVector;
int diffSlots;
if( orbitPoints.isEmpty())//Setup orbitPoins if (orbitPoints.isEmpty())//Setup orbitPoins
{ {
epochTm = epochTime - orbitSpan; epochTm = epoch - orbitSpan;
for(int i=0; i<=orbitLineSegments; i++) for (int i=0; i<=orbitLineSegments; i++)
{ {
pSatellite->setEpoch( epochTm); pSatWrapper->setEpoch(epochTm.getGmtTm());
azElVector = observer.calculateLook( *pSatellite, e elAzVector = pSatWrapper->getAltAz();
pochTm); orbitPoints.append(elAzVector);
orbitPoints.append(azElVector); epochTm += computeInterval;
epochTm += computeInterval;
} }
lastEpochCompForOrbit = epochTime; lastEpochCompForOrbit = epochTime;
} }
else if( epochTime > lastEpochCompForOrbit) else if (epochTime > lastEpochCompForOrbit)
{ // compute next orbit point when clock runs forward { // compute next orbit point when clock runs forward
gTimeSpan diffTime = epochTime - lastEpochCompForOrbit; gTimeSpan diffTime = epoch - lastEpochComp;
diffSlots = (int)(diffTime.getDblSeconds()/orbitLin eSegmentDuration); diffSlots = (int)(diffTime.getDblSeconds()/orbitLin eSegmentDuration);
if(diffSlots > 0) if (diffSlots > 0)
{ {
if( diffSlots > orbitLineSegments) if (diffSlots > orbitLineSegments)
{ {
diffSlots = orbitLineSegments + 1; diffSlots = orbitLineSegments + 1;
epochTm = epochTime - orbitSpan; epochTm = epoch - orbitSpan;
} }
else else
{ {
epochTm = lastEpochCompForOrbit + orbitSpa n + computeInterval; epochTm = lastEpochComp + orbitSpan + comp uteInterval;
} }
for( int i=0; i<diffSlots; i++) for (int i=0; i<diffSlots; i++)
{ //remove points at beginning of list and add poin ts at end. { //remove points at beginning of list and add poin ts at end.
orbitPoints.removeFirst(); orbitPoints.removeFirst();
pSatellite->setEpoch( epochTm); pSatWrapper->setEpoch(epochTm.getGmtTm());
azElVector = observer.calculateLook( *pSate elAzVector = pSatWrapper->getAltAz();
llite, epochTm); orbitPoints.append(elAzVector);
orbitPoints.append(azElVector); epochTm += computeInterval;
epochTm += computeInterval;
} }
lastEpochCompForOrbit = epochTime; lastEpochCompForOrbit = epochTime;
} }
} }
else if(epochTime < lastEpochCompForOrbit) else if (epochTime < lastEpochCompForOrbit)
{ // compute next orbit point when clock runs backward { // compute next orbit point when clock runs backward
gTimeSpan diffTime = lastEpochCompForOrbit - epochTime; gTimeSpan diffTime = lastEpochComp - epoch;
diffSlots = (int)(diffTime.getDblSeconds()/orbitLin eSegmentDuration); diffSlots = (int)(diffTime.getDblSeconds()/orbitLin eSegmentDuration);
if(diffSlots > 0) if (diffSlots > 0)
{ {
if( diffSlots > orbitLineSegments) if (diffSlots > orbitLineSegments)
{ {
diffSlots = orbitLineSegments + 1; diffSlots = orbitLineSegments + 1;
epochTm = epochTime + orbitSpan; epochTm = epoch + orbitSpan;
} }
else else
{ {
epochTm = epochTime - orbitSpan - computeI nterval; epochTm = epoch - orbitSpan - computeInte rval;
} }
for( int i=0; i<diffSlots;i++) for (int i=0; i<diffSlots; i++)
{ //remove points at end of list and add points at b eginning. { //remove points at end of list and add points at b eginning.
orbitPoints.removeLast(); orbitPoints.removeLast();
pSatellite->setEpoch( epochTm); pSatWrapper->setEpoch(epochTm.getGmtTm());
azElVector = observer.calculateLook( *pSate elAzVector = pSatWrapper->getAltAz();
llite, epochTm); orbitPoints.push_front(elAzVector);
orbitPoints.push_front(azElVector);
epochTm -= computeInterval; epochTm -= computeInterval;
} }
lastEpochCompForOrbit = epochTime; lastEpochCompForOrbit = epochTime;
} }
} }
} }
 End of changes. 64 change blocks. 
154 lines changed or deleted 129 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/