StelLocation.cpp   StelLocation.cpp 
skipping to change at line 45 skipping to change at line 45
return QString("%1\t%2\t%3\t%4\t%5\t%6\t%7\t%8\t%9\t%10\t%11\t%12") return QString("%1\t%2\t%3\t%4\t%5\t%6\t%7\t%8\t%9\t%10\t%11\t%12")
.arg(name) .arg(name)
.arg(state) .arg(state)
.arg(country) .arg(country)
.arg(role) .arg(role)
.arg(population/1000) .arg(population/1000)
.arg(latitude<0 ? QString("%1S").arg(-latitude, 0, ' f', 6) : QString("%1N").arg(latitude, 0, 'f', 6)) .arg(latitude<0 ? QString("%1S").arg(-latitude, 0, ' f', 6) : QString("%1N").arg(latitude, 0, 'f', 6))
.arg(longitude<0 ? QString("%1W").arg(-longitude, 0, 'f', 6) : QString("%1E").arg(longitude, 0, 'f', 6)) .arg(longitude<0 ? QString("%1W").arg(-longitude, 0, 'f', 6) : QString("%1E").arg(longitude, 0, 'f', 6))
.arg(altitude) .arg(altitude)
.arg(bortleScaleIndex) .arg(bortleScaleIndex)
.arg("") // Reserve for time zone .arg(timeZone)
.arg(planetName) .arg(planetName)
.arg(landscapeKey); .arg(landscapeKey);
} }
QString StelLocation::getID() const QString StelLocation::getID() const
{ {
if (name.isEmpty()) if (name.isEmpty())
{ {
return QString("%1,%2").arg(latitude).arg(longitude); return QString("%1,%2").arg(latitude).arg(longitude);
} }
QString ret = name; QString ret = name;
if (!country.isEmpty()) if (!country.isEmpty())
ret += ", " + country; ret += ", " + country;
return ret; return ret;
} }
QDataStream& operator<<(QDataStream& out, const StelLocation& loc) QDataStream& operator<<(QDataStream& out, const StelLocation& loc)
{ {
out << loc.name << loc.state << loc.country << loc.role << loc.popul ation << loc.latitude << loc.longitude << loc.altitude << loc.bortleScaleIn dex << loc.planetName << loc.landscapeKey << loc.isUserLocation; out << loc.name << loc.state << loc.country << loc.role << loc.popul ation << loc.latitude << loc.longitude << loc.altitude << loc.bortleScaleIn dex << loc.timeZone << loc.planetName << loc.landscapeKey << loc.isUserLoca tion;
return out; return out;
} }
QDataStream& operator>>(QDataStream& in, StelLocation& loc) QDataStream& operator>>(QDataStream& in, StelLocation& loc)
{ {
in >> loc.name >> loc.state >> loc.country >> loc.role >> loc.popula tion >> loc.latitude >> loc.longitude >> loc.altitude >> loc.bortleScaleInd ex >> loc.planetName >> loc.landscapeKey >> loc.isUserLocation; in >> loc.name >> loc.state >> loc.country >> loc.role >> loc.popula tion >> loc.latitude >> loc.longitude >> loc.altitude >> loc.bortleScaleInd ex >> loc.timeZone >> loc.planetName >> loc.landscapeKey >> loc.isUserLocat ion;
return in; return in;
} }
// Parse a location from a line serialization // Parse a location from a line serialization
StelLocation StelLocation::createFromLine(const QString& rawline) StelLocation StelLocation::createFromLine(const QString& rawline)
{ {
StelLocation loc; StelLocation loc;
const QStringList& splitline = rawline.split("\t"); const QStringList& splitline = rawline.split("\t");
loc.name = splitline.at(0); loc.name = splitline.at(0).trimmed();
loc.state = splitline.at(1); loc.state = splitline.at(1).trimmed();
loc.country = StelLocaleMgr::countryCodeToString(splitline.at(2)); loc.country = StelLocaleMgr::countryCodeToString(splitline.at(2).tri
mmed());
if (loc.country.isEmpty()) if (loc.country.isEmpty())
loc.country = splitline.at(2); loc.country = splitline.at(2).trimmed();
loc.role = splitline.at(3).at(0); loc.role = splitline.at(3).at(0).toUpper();
if (loc.role == '\0') if (loc.role.isNull())
loc.role = 'X'; loc.role = QChar(0x0058); // char 'X'
loc.population = (int) (splitline.at(4).toFloat()*1000); loc.population = (int) (splitline.at(4).toFloat()*1000);
const QString& latstring = splitline.at(5); const QString& latstring = splitline.at(5).trimmed();
loc.latitude = latstring.left(latstring.size() - 1).toFloat(); loc.latitude = latstring.left(latstring.size() - 1).toFloat();
if (latstring.endsWith('S')) if (latstring.endsWith('S'))
loc.latitude=-loc.latitude; loc.latitude=-loc.latitude;
const QString& lngstring = splitline.at(6); const QString& lngstring = splitline.at(6).trimmed();
loc.longitude = lngstring.left(lngstring.size() - 1).toFloat(); loc.longitude = lngstring.left(lngstring.size() - 1).toFloat();
if (lngstring.endsWith('W')) if (lngstring.endsWith('W'))
loc.longitude=-loc.longitude; loc.longitude=-loc.longitude;
loc.altitude = (int)splitline.at(7).toFloat(); loc.altitude = (int)splitline.at(7).toFloat();
if (splitline.size()>8) if (splitline.size()>8)
{ {
bool ok; bool ok;
loc.bortleScaleIndex = splitline.at(8).toInt(&ok); loc.bortleScaleIndex = splitline.at(8).toInt(&ok);
if (ok==false) if (ok==false)
loc.bortleScaleIndex = DEFAULT_BORTLE_SCALE_INDEX; loc.bortleScaleIndex = DEFAULT_BORTLE_SCALE_INDEX;
} }
else else
loc.bortleScaleIndex = DEFAULT_BORTLE_SCALE_INDEX; loc.bortleScaleIndex = DEFAULT_BORTLE_SCALE_INDEX;
// Reserve for TimeZone if (splitline.size()>9)
// if (splitline.size()>9) {} {
// Parse time zone
loc.timeZone = splitline.at(9).trimmed();
}
if (splitline.size()>10) if (splitline.size()>10)
{ {
// Parse planet name // Parse planet name
loc.planetName = splitline.at(10); loc.planetName = splitline.at(10).trimmed();
} }
else else
{ {
// Earth by default // Earth by default
loc.planetName = "Earth"; loc.planetName = "Earth";
} }
if (splitline.size()>11) if (splitline.size()>11)
{ {
// Parse optional associated landscape key // Parse optional associated landscape key
loc.landscapeKey = splitline.at(11); loc.landscapeKey = splitline.at(11).trimmed();
} }
return loc; return loc;
} }
// Compute great-circle distance between two locations // Compute great-circle distance between two locations
float StelLocation::distanceDegrees(const float long1, const float lat1, co nst float long2, const float lat2) float StelLocation::distanceDegrees(const float long1, const float lat1, co nst float long2, const float lat2)
{ {
const float DEGREES=M_PI/180.0f; const float DEGREES=M_PI/180.0f;
return std::acos( std::sin(lat1*DEGREES)*std::sin(lat2*DEGREES) + return std::acos( std::sin(lat1*DEGREES)*std::sin(lat2*DEGREES) +
std::cos(lat1*DEGREES)*std::cos(la std::cos(lat1*DEGREES)*std::cos(lat2*DEGREES) *
t2*DEGREES)*std::cos((long1-long2)*DEGREES) ) / DEGREES; std::cos((long1-long2)*DEGREES) ) / DEGREES;
} }
 End of changes. 12 change blocks. 
18 lines changed or deleted 22 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/