16 #include <QApplication>
17 #include <QStringList>
30 QFile file(
"stars.dat");
31 file.
open(QIODevice::WriteOnly);
35 out << (quint32)0x73746172;
40 QFile data(
"catalog.dat");
41 if ( data.
open( QFile::ReadOnly ) ) {
48 int idValue = idString.
toInt();
56 double raValue = 15 * ( raHH + raMM / 60.0 + raSS / 3600.0 ) / 180.0 *
M_PI;
60 double deSign = ( decString.
mid( 0, 1 ) ==
"-" ) ? -1.0 : 1.0;
65 double deValue = deSign * ( deHH + deMM / 60.0 + deSS / 3600.0 ) / 180.0 *
M_PI;
68 double magValue = magString.
toDouble();
75 double bvValue = bvString.
toDouble();
76 double bvMinDifference = fabs(
colorTable.at(0)-bvValue);
78 double bvDifference = fabs(
colorTable.at(i)-bvValue);
79 if (bvDifference < bvMinDifference) {
81 bvMinDifference = bvDifference;
88 if ( !line.
isNull() && magValue < 6.0 ) {
89 if (raValue != 0 && deValue != 0) {
90 if (idValue != 5958) {
91 qDebug() <<
"ID:" << idValue <<
"RA:" << raValue <<
"DE:" << deValue <<
"mag:" << magValue <<
"B-V:" << bvString <<
"idx:" << colorIdx;
100 }
while ( !line.
isNull() );
107 QFile file(
"kmlsky.kml");
108 file.
open(QIODevice::WriteOnly);
111 out <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
112 <<
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" hint=\"target=sky\"> \n"
114 <<
" <Style id=\"mag-1 blue\"> \n"
117 <<
" <href>data/star_0_blue.png</href> \n"
119 <<
" </IconStyle> \n"
121 <<
" <Style id=\"mag0 blue\"> \n"
124 <<
" <href>data/star_1_blue.png</href> \n"
126 <<
" </IconStyle> \n"
128 <<
" <Style id=\"mag1 blue\"> \n"
131 <<
" <href>data/star_2_blue.png</href> \n"
133 <<
" </IconStyle> \n"
135 <<
" <Style id=\"mag2 blue\"> \n"
138 <<
" <href>data/star_3_blue.png</href> \n"
140 <<
" </IconStyle> \n"
142 <<
" <Style id=\"mag3 blue\"> \n"
145 <<
" <href>data/star_4_blue.png</href> \n"
147 <<
" </IconStyle> \n"
149 <<
" <Style id=\"mag4 blue\"> \n"
152 <<
" <href>data/star_5_blue.png</href> \n"
154 <<
" </IconStyle> \n"
156 <<
" <Style id=\"mag5 blue\"> \n"
159 <<
" <href>data/star_6_blue.png</href> \n"
161 <<
" </IconStyle> \n"
163 <<
" <Style id=\"mag6 blue\"> \n"
166 <<
" <href>data/star_7_blue.png</href> \n"
168 <<
" </IconStyle> \n"
170 <<
" <Style id=\"mag7 blue\"> \n"
173 <<
" <href>data/star_8_blue.png</href> \n"
175 <<
" </IconStyle> \n"
177 <<
" <Style id=\"mag-1 bluewhite\"> \n"
180 <<
" <href>data/star_0_bluewhite.png</href> \n"
182 <<
" </IconStyle> \n"
184 <<
" <Style id=\"mag0 bluewhite\"> \n"
187 <<
" <href>data/star_1_bluewhite.png</href> \n"
189 <<
" </IconStyle> \n"
191 <<
" <Style id=\"mag1 bluewhite\"> \n"
194 <<
" <href>data/star_2_bluewhite.png</href> \n"
196 <<
" </IconStyle> \n"
198 <<
" <Style id=\"mag2 bluewhite\"> \n"
201 <<
" <href>data/star_3_bluewhite.png</href> \n"
203 <<
" </IconStyle> \n"
205 <<
" <Style id=\"mag3 bluewhite\"> \n"
208 <<
" <href>data/star_4_bluewhite.png</href> \n"
210 <<
" </IconStyle> \n"
212 <<
" <Style id=\"mag4 bluewhite\"> \n"
215 <<
" <href>data/star_5_bluewhite.png</href> \n"
217 <<
" </IconStyle> \n"
219 <<
" <Style id=\"mag5 bluewhite\"> \n"
222 <<
" <href>data/star_6_bluewhite.png</href> \n"
224 <<
" </IconStyle> \n"
226 <<
" <Style id=\"mag6 bluewhite\"> \n"
229 <<
" <href>data/star_7_bluewhite.png</href> \n"
231 <<
" </IconStyle> \n"
233 <<
" <Style id=\"mag7 bluewhite\"> \n"
236 <<
" <href>data/star_8_bluewhite.png</href> \n"
238 <<
" </IconStyle> \n"
240 <<
" <Style id=\"mag-1 white\"> \n"
243 <<
" <href>data/star_0_white.png</href> \n"
245 <<
" </IconStyle> \n"
247 <<
" <Style id=\"mag0 white\"> \n"
250 <<
" <href>data/star_1_white.png</href> \n"
252 <<
" </IconStyle> \n"
254 <<
" <Style id=\"mag1 white\"> \n"
257 <<
" <href>data/star_2_white.png</href> \n"
259 <<
" </IconStyle> \n"
261 <<
" <Style id=\"mag2 white\"> \n"
264 <<
" <href>data/star_3_white.png</href> \n"
266 <<
" </IconStyle> \n"
268 <<
" <Style id=\"mag3 white\"> \n"
271 <<
" <href>data/star_4_white.png</href> \n"
273 <<
" </IconStyle> \n"
275 <<
" <Style id=\"mag4 white\"> \n"
278 <<
" <href>data/star_5_white.png</href> \n"
280 <<
" </IconStyle> \n"
282 <<
" <Style id=\"mag5 white\"> \n"
285 <<
" <href>data/star_6_white.png</href> \n"
287 <<
" </IconStyle> \n"
289 <<
" <Style id=\"mag6 white\"> \n"
292 <<
" <href>data/star_7_white.png</href> \n"
294 <<
" </IconStyle> \n"
296 <<
" <Style id=\"mag7 white\"> \n"
299 <<
" <href>data/star_8_white.png</href> \n"
301 <<
" </IconStyle> \n"
303 <<
" <Style id=\"mag-1 yellow\"> \n"
306 <<
" <href>data/star_0_yellow.png</href> \n"
308 <<
" </IconStyle> \n"
310 <<
" <Style id=\"mag0 yellow\"> \n"
313 <<
" <href>data/star_1_yellow.png</href> \n"
315 <<
" </IconStyle> \n"
317 <<
" <Style id=\"mag1 yellow\"> \n"
320 <<
" <href>data/star_2_yellow.png</href> \n"
322 <<
" </IconStyle> \n"
324 <<
" <Style id=\"mag2 yellow\"> \n"
327 <<
" <href>data/star_3_yellow.png</href> \n"
329 <<
" </IconStyle> \n"
331 <<
" <Style id=\"mag3 yellow\"> \n"
334 <<
" <href>data/star_4_yellow.png</href> \n"
336 <<
" </IconStyle> \n"
338 <<
" <Style id=\"mag4 yellow\"> \n"
341 <<
" <href>data/star_5_yellow.png</href> \n"
343 <<
" </IconStyle> \n"
345 <<
" <Style id=\"mag5 yellow\"> \n"
348 <<
" <href>data/star_6_yellow.png</href> \n"
350 <<
" </IconStyle> \n"
352 <<
" <Style id=\"mag6 yellow\"> \n"
355 <<
" <href>data/star_7_yellow.png</href> \n"
357 <<
" </IconStyle> \n"
359 <<
" <Style id=\"mag7 yellow\"> \n"
362 <<
" <href>data/star_8_yellow.png</href> \n"
364 <<
" </IconStyle> \n"
366 <<
" <Style id=\"mag-1 orange\"> \n"
369 <<
" <href>data/star_0_orange.png</href> \n"
371 <<
" </IconStyle> \n"
373 <<
" <Style id=\"mag0 orange\"> \n"
376 <<
" <href>data/star_1_orange.png</href> \n"
378 <<
" </IconStyle> \n"
380 <<
" <Style id=\"mag1 orange\"> \n"
383 <<
" <href>data/star_2_orange.png</href> \n"
385 <<
" </IconStyle> \n"
387 <<
" <Style id=\"mag2 orange\"> \n"
390 <<
" <href>data/star_3_orange.png</href> \n"
392 <<
" </IconStyle> \n"
394 <<
" <Style id=\"mag3 orange\"> \n"
397 <<
" <href>data/star_4_orange.png</href> \n"
399 <<
" </IconStyle> \n"
401 <<
" <Style id=\"mag4 orange\"> \n"
404 <<
" <href>data/star_5_orange.png</href> \n"
406 <<
" </IconStyle> \n"
408 <<
" <Style id=\"mag5 orange\"> \n"
411 <<
" <href>data/star_6_orange.png</href> \n"
413 <<
" </IconStyle> \n"
415 <<
" <Style id=\"mag6 orange\"> \n"
418 <<
" <href>data/star_7_orange.png</href> \n"
420 <<
" </IconStyle> \n"
422 <<
" <Style id=\"mag7 orange\"> \n"
425 <<
" <href>data/star_8_orange.png</href> \n"
427 <<
" </IconStyle> \n"
429 <<
" <Style id=\"mag-1 red\"> \n"
432 <<
" <href>data/star_0_red.png</href> \n"
434 <<
" </IconStyle> \n"
436 <<
" <Style id=\"mag0 red\"> \n"
439 <<
" <href>data/star_1_red.png</href> \n"
441 <<
" </IconStyle> \n"
443 <<
" <Style id=\"mag1 red\"> \n"
446 <<
" <href>data/star_2_red.png</href> \n"
448 <<
" </IconStyle> \n"
450 <<
" <Style id=\"mag2 red\"> \n"
453 <<
" <href>data/star_3_red.png</href> \n"
455 <<
" </IconStyle> \n"
457 <<
" <Style id=\"mag3 red\"> \n"
460 <<
" <href>data/star_4_red.png</href> \n"
462 <<
" </IconStyle> \n"
464 <<
" <Style id=\"mag4 red\"> \n"
467 <<
" <href>data/star_5_red.png</href> \n"
469 <<
" </IconStyle> \n"
471 <<
" <Style id=\"mag5 red\"> \n"
474 <<
" <href>data/star_6_red.png</href> \n"
476 <<
" </IconStyle> \n"
478 <<
" <Style id=\"mag6 red\"> \n"
481 <<
" <href>data/star_7_red.png</href> \n"
483 <<
" </IconStyle> \n"
485 <<
" <Style id=\"mag7 red\"> \n"
488 <<
" <href>data/star_8_red.png</href> \n"
490 <<
" </IconStyle> \n"
492 <<
" <Style id=\"mag-1 garnetred\"> \n"
495 <<
" <href>data/star_0_garnetred.png</href> \n"
497 <<
" </IconStyle> \n"
499 <<
" <Style id=\"mag0 garnetred\"> \n"
502 <<
" <href>data/star_1_garnetred.png</href> \n"
504 <<
" </IconStyle> \n"
506 <<
" <Style id=\"mag1 garnetred\"> \n"
509 <<
" <href>data/star_2_garnetred.png</href> \n"
511 <<
" </IconStyle> \n"
513 <<
" <Style id=\"mag2 garnetred\"> \n"
516 <<
" <href>data/star_3_garnetred.png</href> \n"
518 <<
" </IconStyle> \n"
520 <<
" <Style id=\"mag3 garnetred\"> \n"
523 <<
" <href>data/star_4_garnetred.png</href> \n"
525 <<
" </IconStyle> \n"
527 <<
" <Style id=\"mag4 garnetred\"> \n"
530 <<
" <href>data/star_5_garnetred.png</href> \n"
532 <<
" </IconStyle> \n"
534 <<
" <Style id=\"mag5 garnetred\"> \n"
537 <<
" <href>data/star_6_garnetred.png</href> \n"
539 <<
" </IconStyle> \n"
541 <<
" <Style id=\"mag6 garnetred\"> \n"
544 <<
" <href>data/star_7_garnetred.png</href> \n"
546 <<
" </IconStyle> \n"
548 <<
" <Style id=\"mag7 garnetred\"> \n"
551 <<
" <href>data/star_8_garnetred.png</href> \n"
553 <<
" </IconStyle> \n"
556 QFile data(
"catalog.dat");
557 if ( data.
open( QFile::ReadOnly ) ) {
568 qreal longitude = ( raHH + raMM / 60.0 + raSS / 3600.0 ) * 15.0 - 180.0;
571 double deSign = ( decString.
mid( 0, 1 ) ==
"-" ) ? -1.0 : 1.0;
576 double deValue = deSign * ( deHH + deMM / 60.0 + deSS / 3600.0 );
578 qreal latitude = deValue;
581 double magValue = magString.
toDouble();
588 double bvValue = bvString.
toDouble();
589 double bvMinDifference = fabs(
colorTable.at(0)-bvValue);
591 double bvDifference = fabs(
colorTable.at(i)-bvValue);
592 if (bvDifference < bvMinDifference) {
594 bvMinDifference = bvDifference;
600 if ( magValue < -1 ) {
603 else if ( magValue < 0 && magValue > -1 ) {
606 else if ( magValue < 1 && magValue > 0 ) {
609 else if ( magValue < 2 && magValue > 1 ) {
612 else if ( magValue < 3 && magValue > 2 ) {
615 else if ( magValue < 4 && magValue > 3 ) {
618 else if ( magValue < 5 && magValue > 4 ) {
621 else if ( magValue < 6 && magValue > 5 ) {
628 if ( colorIdx == 0 ) {
630 }
else if ( colorIdx == 1 ) {
631 styleId +=
" bluewhite";
632 }
else if ( colorIdx == 3 ) {
633 styleId +=
" yellow";
634 }
else if ( colorIdx == 4 ) {
635 styleId +=
" orange";
636 }
else if ( colorIdx == 5 ) {
638 }
else if ( colorIdx == 6 ) {
639 styleId +=
" garnetred";
645 out <<
" <Placemark> \n";
648 if ( name ==
"Alp" ) {
650 }
else if ( name ==
"Bet" ) {
652 }
else if ( name ==
"Gam" ) {
654 }
else if ( name ==
"Del" ) {
656 }
else if ( name ==
"Eps" ) {
660 out <<
" <styleUrl>#" << styleId <<
"</styleUrl> \n"
662 <<
" <coordinates>" << longitude <<
"," << latitude <<
",0" <<
"</coordinates> \n"
664 <<
" </Placemark> \n";
666 }
while ( !line.
isNull() );
669 out <<
"</Document> \n"
675 int main(
int argc,
char *argv[])
681 std::cerr <<
"Missing stars.dat in current directory. Exiting." << std::endl;
696 QFile starFile(
"stars.dat");
697 starFile.
open(QIODevice::ReadOnly);
702 if (magic != 0x73746172)
709 qDebug() <<
"stars.dat: file too new.";
718 while ( !in.
atEnd() ) {
724 qDebug() <<
"ID:" <<
id <<
"RA:" << ra <<
"DE:" << de <<
"MAG:" << mag <<
"idx:" << colorIdx;
QVector< double > colorTable(0)
QString readLine(qint64 maxlen)
double toDouble(bool *ok) const
void exit(int returnCode)
QString fromUtf8(const char *str, int size)
int toInt(bool *ok, int base) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QString mid(int position, int n) const
int main(int argc, char *argv[])