Location.cpp   StelLocation.cpp 
skipping to change at line 19 skipping to change at line 19
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "Location.hpp" #include "StelLocation.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include <QStringList> #include <QStringList>
// Output the location as a string ready to be stored in the user_location file // Output the location as a string ready to be stored in the user_location file
QString Location::serializeToLine() const QString StelLocation::serializeToLine() const
{ {
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', 3) : QString("%1N").arg(latitude, 0, 'f', 3)) .arg(latitude<0 ? QString("%1S").arg(-latitude, 0, ' f', 3) : QString("%1N").arg(latitude, 0, 'f', 3))
.arg(longitude<0 ? QString("%1W").arg(-longitude, 0, 'f', 3) : QString("%1E").arg(longitude, 0, 'f', 3)) .arg(longitude<0 ? QString("%1W").arg(-longitude, 0, 'f', 3) : QString("%1E").arg(longitude, 0, 'f', 3))
.arg(altitude) .arg(altitude)
.arg(bortleScaleIndex) .arg(bortleScaleIndex)
.arg("") // Reserve for time zone .arg("") // Reserve for time zone
.arg(planetName) .arg(planetName)
.arg(landscapeKey); .arg(landscapeKey);
} }
// Parse a location from a line serialization // Parse a location from a line serialization
Location Location::createFromLine(const QString& rawline) StelLocation StelLocation::createFromLine(const QString& rawline)
{ {
Location loc; StelLocation loc;
const QStringList& splitline = rawline.split("\t"); const QStringList& splitline = rawline.split("\t");
loc.name = splitline[0]; loc.name = splitline[0];
loc.state = splitline[1]; loc.state = splitline[1];
loc.country = StelLocaleMgr::countryCodeToString(splitline[2]); loc.country = StelLocaleMgr::countryCodeToString(splitline[2]);
if (loc.country.isEmpty()) if (loc.country.isEmpty())
loc.country = splitline[2]; loc.country = splitline[2];
loc.role = splitline[3].at(0); loc.role = splitline[3].at(0);
loc.population = (int) ( 1000 * splitline[4].toFloat() ); loc.population = (int) ( 1000 * splitline[4].toFloat() );
const QString& latstring = splitline[5]; const QString& latstring = splitline[5];
loc.latitude = latstring.left(latstring.size() - 1).toDouble(); loc.latitude = latstring.left(latstring.size() - 1).toDouble();
if (latstring.contains("S")) if (latstring.contains("S"))
loc.latitude=-loc.latitude; loc.latitude=-loc.latitude;
const QString& lngstring = splitline[6]; const QString& lngstring = splitline[6];
loc.longitude = lngstring.left(lngstring.size() - 1).toDouble(); loc.longitude = lngstring.left(lngstring.size() - 1).toDouble();
if (lngstring.contains("W")) if (lngstring.contains("W"))
loc.longitude=-loc.longitude; loc.longitude=-loc.longitude;
loc.altitude = (splitline[7]).toInt(); loc.altitude = (int)(splitline[7]).toFloat();
if (splitline.size()>8) if (splitline.size()>8)
{ {
bool ok; bool ok;
loc.bortleScaleIndex = (splitline[8]).toInt(&ok); loc.bortleScaleIndex = (splitline[8]).toInt(&ok);
if (ok==false) if (ok==false)
loc.bortleScaleIndex = 2; loc.bortleScaleIndex = 2;
} }
else else
loc.bortleScaleIndex = 2; loc.bortleScaleIndex = 2;
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 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/