7#include "modcalcgeodcoord.h"
10#include "geolocation.h"
12#include "ksnotification.h"
13#include "kstarsdata.h"
18modCalcGeodCoord::modCalcGeodCoord(
QWidget *parentSplit) :
QFrame(parentSplit)
22 ellipsoidList <<
"IAU76"
30 spheRadio->setChecked(
true);
31 ellipsoidBox->insertItems(5, ellipsoidList);
37 connect(Clear, SIGNAL(clicked()),
this, SLOT(slotClearGeoCoords()));
38 connect(Compute, SIGNAL(clicked()),
this, SLOT(slotComputeGeoCoords()));
41void modCalcGeodCoord::showLongLat(
void)
45 LongGeoBox->show(data->
geo()->
lng());
46 LatGeoBox->show(data->
geo()->
lat());
47 AltGeoBox->setText(
QString(
"0.0"));
50void modCalcGeodCoord::setEllipsoid(
int index)
52 geoPlace->changeEllipsoid(index);
55void modCalcGeodCoord::getCartGeoCoords(
void)
57 geoPlace->setXPos(XGeoBox->text().toDouble() * 1000.);
58 geoPlace->setYPos(YGeoBox->text().toDouble() * 1000.);
59 geoPlace->setZPos(ZGeoBox->text().toDouble() * 1000.);
62void modCalcGeodCoord::getSphGeoCoords(
void)
64 geoPlace->setLong(LongGeoBox->createDms());
65 geoPlace->setLat(LatGeoBox->createDms());
66 geoPlace->setElevation(AltGeoBox->text().toDouble());
69void modCalcGeodCoord::slotClearGeoCoords(
void)
71 geoPlace->setLong(
dms(0.0));
72 geoPlace->setLat(
dms(0.0));
73 geoPlace->setElevation(0.0);
74 LatGeoBox->clearFields();
75 LongGeoBox->clearFields();
78void modCalcGeodCoord::slotComputeGeoCoords(
void)
80 if (cartRadio->isChecked())
92void modCalcGeodCoord::showSpheGeoCoords(
void)
94 LongGeoBox->show(geoPlace->lng());
95 LatGeoBox->show(geoPlace->lat());
99void modCalcGeodCoord::showCartGeoCoords(
void)
106void modCalcGeodCoord::geoCheck(
void)
108 XGeoBoxBatch->setEnabled(
false);
109 XGeoCheckBatch->setChecked(
false);
110 YGeoBoxBatch->setEnabled(
false);
111 YGeoCheckBatch->setChecked(
false);
112 YGeoBoxBatch->setEnabled(
false);
113 YGeoCheckBatch->setChecked(
false);
114 xyzInputCoords =
false;
117void modCalcGeodCoord::xyzCheck(
void)
119 LongGeoBoxBatch->setEnabled(
false);
120 LongGeoCheckBatch->setChecked(
false);
121 LatGeoBoxBatch->setEnabled(
false);
122 LatGeoCheckBatch->setChecked(
false);
123 AltGeoBoxBatch->setEnabled(
false);
124 AltGeoCheckBatch->setChecked(
false);
125 xyzInputCoords =
true;
128void modCalcGeodCoord::slotLongCheckedBatch()
130 if (LongGeoCheckBatch->isChecked())
132 LongGeoBoxBatch->setEnabled(
false);
137 LongGeoBoxBatch->setEnabled(
true);
141void modCalcGeodCoord::slotLatCheckedBatch()
143 if (LatGeoCheckBatch->isChecked())
145 LatGeoBoxBatch->setEnabled(
false);
150 LatGeoBoxBatch->setEnabled(
true);
154void modCalcGeodCoord::slotElevCheckedBatch()
156 if (AltGeoCheckBatch->isChecked())
158 AltGeoBoxBatch->setEnabled(
false);
163 AltGeoBoxBatch->setEnabled(
true);
167void modCalcGeodCoord::slotXCheckedBatch()
169 if (XGeoCheckBatch->isChecked())
171 XGeoBoxBatch->setEnabled(
false);
176 XGeoBoxBatch->setEnabled(
true);
180void modCalcGeodCoord::slotYCheckedBatch()
182 if (YGeoCheckBatch->isChecked())
184 YGeoBoxBatch->setEnabled(
false);
189 YGeoBoxBatch->setEnabled(
true);
193void modCalcGeodCoord::slotZCheckedBatch()
195 if (ZGeoCheckBatch->isChecked())
197 ZGeoBoxBatch->setEnabled(
false);
202 ZGeoBoxBatch->setEnabled(
true);
205void modCalcGeodCoord::slotInputFile()
212void modCalcGeodCoord::slotOutputFile()
219void modCalcGeodCoord::slotRunBatch(
void)
221 const QString inputFileName = InputFileBoxBatch->url().toLocalFile();
227 QFile f(inputFileName);
230 QString message =
i18n(
"Could not open file %1.", f.fileName());
231 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
237 processLines(istream);
243 QString message =
i18n(
"Invalid file: %1", inputFileName);
244 KSNotification::sorry(message,
i18n(
"Invalid file"));
245 InputFileBoxBatch->setUrl(
QUrl());
249void modCalcGeodCoord::processLines(
QTextStream &istream)
254 const QString outputFileName = OutputFileBoxBatch->url().toLocalFile();
255 QFile fOut(outputFileName);
263 geoPl.setEllipsoid(0);
265 double xB, yB, zB, hB;
268 while (!istream.
atEnd())
285 if (XGeoCheckBatch->isChecked())
287 xB = fields[i].toDouble();
291 xB = XGeoBoxBatch->text().toDouble();
293 if (AllRadioBatch->isChecked())
294 ostream << xB << space;
295 else if (XGeoCheckBatch->isChecked())
296 ostream << xB << space;
300 if (YGeoCheckBatch->isChecked())
302 yB = fields[i].toDouble();
306 yB = YGeoBoxBatch->text().toDouble();
308 if (AllRadioBatch->isChecked())
309 ostream << yB << space;
310 else if (YGeoCheckBatch->isChecked())
311 ostream << yB << space;
314 if (ZGeoCheckBatch->isChecked())
316 zB = fields[i].toDouble();
320 zB = ZGeoBoxBatch->text().toDouble();
322 if (AllRadioBatch->isChecked())
323 ostream << zB << space;
324 else if (YGeoCheckBatch->isChecked())
325 ostream << zB << space;
327 geoPl.setXPos(xB * 1000.0);
328 geoPl.setYPos(yB * 1000.0);
329 geoPl.setZPos(zB * 1000.0);
330 ostream << geoPl.lng()->toDMSString() << space << geoPl.lat()->toDMSString() << space << geoPl.elevation()
339 if (LongGeoCheckBatch->isChecked())
345 longB = LongGeoBoxBatch->createDms();
347 if (AllRadioBatch->isChecked())
349 else if (LongGeoCheckBatch->isChecked())
354 if (LatGeoCheckBatch->isChecked())
360 latB = LatGeoBoxBatch->createDms();
362 if (AllRadioBatch->isChecked())
364 else if (LatGeoCheckBatch->isChecked())
369 if (AltGeoCheckBatch->isChecked())
371 hB = fields[i].toDouble();
375 hB = AltGeoBoxBatch->text().toDouble();
377 if (AllRadioBatch->isChecked())
378 ostream << hB << space;
379 else if (AltGeoCheckBatch->isChecked())
380 ostream << hB << space;
382 geoPl.setLong(longB);
384 geoPl.setElevation(hB);
386 ostream << geoPl.xPos() / 1000.0 << space << geoPl.yPos() / 1000.0 << space << geoPl.zPos() / 1000.0
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
const CachingDms * lat() const
const CachingDms * lng() const
KStarsData is the backbone of KStars.
static KStars * Instance()
An angle, stored as degrees, but expressible in many ways.
static dms fromString(const QString &s, bool deg)
Static function to create a DMS object from a QString.
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
bool exists() const const
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
bool isEmpty() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString trimmed() const const
QString readLine(qint64 maxlen)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)