• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • tools
  • stars
stars.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2006-2007 Torsten Rahn <tackat@kde.org>
9 // Copyright 2007 Inge Wallin <ingwa@kde.org>
10 // Copyright 2013 Mohammed Nafees <nafees.technocool@gmail.com>
11 //
12 
13 
14 #include <QFile>
15 #include <QDebug>
16 #include <QApplication>
17 #include <QStringList>
18 #include <QFileInfo>
19 
20 #include <cmath>
21 #include <iostream>
22 
23 #define ENABLEGUI
24 
25 // Set up Color Table Per B-V Color indices from some Reference Stars
26 QVector<double> colorTable( 0 );
27 
28 void exportToDat()
29 {
30  QFile file("stars.dat");
31  file.open(QIODevice::WriteOnly);
32  QDataStream out(&file);
33 
34  // Write a header with a "magic number" and a version
35  out << (quint32)0x73746172;
36  out << (qint32)004;
37 
38  out.setVersion(QDataStream::Qt_4_3);
39 
40  QFile data("catalog.dat");
41  if ( data.open( QFile::ReadOnly ) ) {
42  QTextStream stream(&data);
43  QString line;
44  do {
45  line = stream.readLine();
46 
47  QString idString = line.mid(0,4);
48  int idValue = idString.toInt();
49 
50  QString recString = line.mid( 75, 6 );
51 
52  double raHH = recString.mid( 0, 2 ).toDouble();
53  double raMM = recString.mid( 2, 2 ).toDouble();
54  double raSS = recString.mid( 4, 2 ).toDouble();
55 
56  double raValue = 15 * ( raHH + raMM / 60.0 + raSS / 3600.0 ) / 180.0 * M_PI;
57 
58  QString decString = line.mid( 83, 7 );
59 
60  double deSign = ( decString.mid( 0, 1 ) == "-" ) ? -1.0 : 1.0;
61  double deHH = decString.mid( 1, 2 ).toDouble();
62  double deMM = decString.mid( 3, 2 ).toDouble();
63  double deSS = decString.mid( 5, 2 ).toDouble();
64 
65  double deValue = deSign * ( deHH + deMM / 60.0 + deSS / 3600.0 ) / 180.0 * M_PI;
66 
67  QString magString = line.mid( 102, 5 );
68  double magValue = magString.toDouble();
69 
70  QString bvString = line.mid( 108, 6);
71  int colorIdx = 2; // Default White
72 
73  // Find Index of Table Entry with Closest B-V value (Smallest Difference)
74  if(bvString != QString(" ")) {
75  double bvValue = bvString.toDouble();
76  double bvMinDifference = fabs(colorTable.at(0)-bvValue);
77  for (int i = 1; i < colorTable.size(); ++i) {
78  double bvDifference = fabs(colorTable.at(i)-bvValue);
79  if (bvDifference < bvMinDifference) {
80  colorIdx = i;
81  bvMinDifference = bvDifference;
82  }
83  }
84  }
85 
86 
87 // qDebug() << "Rec:" << recString << "Dec.:" << decString << "Mag.:" << magString;
88  if ( !line.isNull() && magValue < 6.0 ) {
89  if (raValue != 0 && deValue != 0) { // Filter out Novae and DSOs
90  if (idValue != 5958) { // Filter out special cases, like novae ( T CrB, ... )
91  qDebug() << "ID:" << idValue << "RA:" << raValue << "DE:" << deValue << "mag:" << magValue << "B-V:" << bvString << "idx:" << colorIdx;
92  out << idValue;
93  out << raValue;
94  out << deValue;
95  out << magValue;
96  out << colorIdx;
97  }
98  }
99  }
100  } while ( !line.isNull() );
101  }
102  file.flush();
103 }
104 
105 void exportToKml()
106 {
107  QFile file("kmlsky.kml");
108  file.open(QIODevice::WriteOnly);
109  QTextStream out(&file);
110 
111  out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
112  << "<kml xmlns=\"http://earth.google.com/kml/2.2\" hint=\"target=sky\"> \n"
113  << "<Document> \n"
114  << " <Style id=\"mag-1 blue\"> \n"
115  << " <IconStyle> \n"
116  << " <Icon> \n"
117  << " <href>data/star_0_blue.png</href> \n"
118  << " </Icon> \n"
119  << " </IconStyle> \n"
120  << " </Style> \n"
121  << " <Style id=\"mag0 blue\"> \n"
122  << " <IconStyle> \n"
123  << " <Icon> \n"
124  << " <href>data/star_1_blue.png</href> \n"
125  << " </Icon> \n"
126  << " </IconStyle> \n"
127  << " </Style> \n"
128  << " <Style id=\"mag1 blue\"> \n"
129  << " <IconStyle> \n"
130  << " <Icon> \n"
131  << " <href>data/star_2_blue.png</href> \n"
132  << " </Icon> \n"
133  << " </IconStyle> \n"
134  << " </Style> \n"
135  << " <Style id=\"mag2 blue\"> \n"
136  << " <IconStyle> \n"
137  << " <Icon> \n"
138  << " <href>data/star_3_blue.png</href> \n"
139  << " </Icon> \n"
140  << " </IconStyle> \n"
141  << " </Style> \n"
142  << " <Style id=\"mag3 blue\"> \n"
143  << " <IconStyle> \n"
144  << " <Icon> \n"
145  << " <href>data/star_4_blue.png</href> \n"
146  << " </Icon> \n"
147  << " </IconStyle> \n"
148  << " </Style> \n"
149  << " <Style id=\"mag4 blue\"> \n"
150  << " <IconStyle> \n"
151  << " <Icon> \n"
152  << " <href>data/star_5_blue.png</href> \n"
153  << " </Icon> \n"
154  << " </IconStyle> \n"
155  << " </Style> \n"
156  << " <Style id=\"mag5 blue\"> \n"
157  << " <IconStyle> \n"
158  << " <Icon> \n"
159  << " <href>data/star_6_blue.png</href> \n"
160  << " </Icon> \n"
161  << " </IconStyle> \n"
162  << " </Style> \n"
163  << " <Style id=\"mag6 blue\"> \n"
164  << " <IconStyle> \n"
165  << " <Icon> \n"
166  << " <href>data/star_7_blue.png</href> \n"
167  << " </Icon> \n"
168  << " </IconStyle> \n"
169  << " </Style> \n"
170  << " <Style id=\"mag7 blue\"> \n"
171  << " <IconStyle> \n"
172  << " <Icon> \n"
173  << " <href>data/star_8_blue.png</href> \n"
174  << " </Icon> \n"
175  << " </IconStyle> \n"
176  << " </Style> \n"
177  << " <Style id=\"mag-1 bluewhite\"> \n"
178  << " <IconStyle> \n"
179  << " <Icon> \n"
180  << " <href>data/star_0_bluewhite.png</href> \n"
181  << " </Icon> \n"
182  << " </IconStyle> \n"
183  << " </Style> \n"
184  << " <Style id=\"mag0 bluewhite\"> \n"
185  << " <IconStyle> \n"
186  << " <Icon> \n"
187  << " <href>data/star_1_bluewhite.png</href> \n"
188  << " </Icon> \n"
189  << " </IconStyle> \n"
190  << " </Style> \n"
191  << " <Style id=\"mag1 bluewhite\"> \n"
192  << " <IconStyle> \n"
193  << " <Icon> \n"
194  << " <href>data/star_2_bluewhite.png</href> \n"
195  << " </Icon> \n"
196  << " </IconStyle> \n"
197  << " </Style> \n"
198  << " <Style id=\"mag2 bluewhite\"> \n"
199  << " <IconStyle> \n"
200  << " <Icon> \n"
201  << " <href>data/star_3_bluewhite.png</href> \n"
202  << " </Icon> \n"
203  << " </IconStyle> \n"
204  << " </Style> \n"
205  << " <Style id=\"mag3 bluewhite\"> \n"
206  << " <IconStyle> \n"
207  << " <Icon> \n"
208  << " <href>data/star_4_bluewhite.png</href> \n"
209  << " </Icon> \n"
210  << " </IconStyle> \n"
211  << " </Style> \n"
212  << " <Style id=\"mag4 bluewhite\"> \n"
213  << " <IconStyle> \n"
214  << " <Icon> \n"
215  << " <href>data/star_5_bluewhite.png</href> \n"
216  << " </Icon> \n"
217  << " </IconStyle> \n"
218  << " </Style> \n"
219  << " <Style id=\"mag5 bluewhite\"> \n"
220  << " <IconStyle> \n"
221  << " <Icon> \n"
222  << " <href>data/star_6_bluewhite.png</href> \n"
223  << " </Icon> \n"
224  << " </IconStyle> \n"
225  << " </Style> \n"
226  << " <Style id=\"mag6 bluewhite\"> \n"
227  << " <IconStyle> \n"
228  << " <Icon> \n"
229  << " <href>data/star_7_bluewhite.png</href> \n"
230  << " </Icon> \n"
231  << " </IconStyle> \n"
232  << " </Style> \n"
233  << " <Style id=\"mag7 bluewhite\"> \n"
234  << " <IconStyle> \n"
235  << " <Icon> \n"
236  << " <href>data/star_8_bluewhite.png</href> \n"
237  << " </Icon> \n"
238  << " </IconStyle> \n"
239  << " </Style> \n"
240  << " <Style id=\"mag-1 white\"> \n"
241  << " <IconStyle> \n"
242  << " <Icon> \n"
243  << " <href>data/star_0_white.png</href> \n"
244  << " </Icon> \n"
245  << " </IconStyle> \n"
246  << " </Style> \n"
247  << " <Style id=\"mag0 white\"> \n"
248  << " <IconStyle> \n"
249  << " <Icon> \n"
250  << " <href>data/star_1_white.png</href> \n"
251  << " </Icon> \n"
252  << " </IconStyle> \n"
253  << " </Style> \n"
254  << " <Style id=\"mag1 white\"> \n"
255  << " <IconStyle> \n"
256  << " <Icon> \n"
257  << " <href>data/star_2_white.png</href> \n"
258  << " </Icon> \n"
259  << " </IconStyle> \n"
260  << " </Style> \n"
261  << " <Style id=\"mag2 white\"> \n"
262  << " <IconStyle> \n"
263  << " <Icon> \n"
264  << " <href>data/star_3_white.png</href> \n"
265  << " </Icon> \n"
266  << " </IconStyle> \n"
267  << " </Style> \n"
268  << " <Style id=\"mag3 white\"> \n"
269  << " <IconStyle> \n"
270  << " <Icon> \n"
271  << " <href>data/star_4_white.png</href> \n"
272  << " </Icon> \n"
273  << " </IconStyle> \n"
274  << " </Style> \n"
275  << " <Style id=\"mag4 white\"> \n"
276  << " <IconStyle> \n"
277  << " <Icon> \n"
278  << " <href>data/star_5_white.png</href> \n"
279  << " </Icon> \n"
280  << " </IconStyle> \n"
281  << " </Style> \n"
282  << " <Style id=\"mag5 white\"> \n"
283  << " <IconStyle> \n"
284  << " <Icon> \n"
285  << " <href>data/star_6_white.png</href> \n"
286  << " </Icon> \n"
287  << " </IconStyle> \n"
288  << " </Style> \n"
289  << " <Style id=\"mag6 white\"> \n"
290  << " <IconStyle> \n"
291  << " <Icon> \n"
292  << " <href>data/star_7_white.png</href> \n"
293  << " </Icon> \n"
294  << " </IconStyle> \n"
295  << " </Style> \n"
296  << " <Style id=\"mag7 white\"> \n"
297  << " <IconStyle> \n"
298  << " <Icon> \n"
299  << " <href>data/star_8_white.png</href> \n"
300  << " </Icon> \n"
301  << " </IconStyle> \n"
302  << " </Style> \n"
303  << " <Style id=\"mag-1 yellow\"> \n"
304  << " <IconStyle> \n"
305  << " <Icon> \n"
306  << " <href>data/star_0_yellow.png</href> \n"
307  << " </Icon> \n"
308  << " </IconStyle> \n"
309  << " </Style> \n"
310  << " <Style id=\"mag0 yellow\"> \n"
311  << " <IconStyle> \n"
312  << " <Icon> \n"
313  << " <href>data/star_1_yellow.png</href> \n"
314  << " </Icon> \n"
315  << " </IconStyle> \n"
316  << " </Style> \n"
317  << " <Style id=\"mag1 yellow\"> \n"
318  << " <IconStyle> \n"
319  << " <Icon> \n"
320  << " <href>data/star_2_yellow.png</href> \n"
321  << " </Icon> \n"
322  << " </IconStyle> \n"
323  << " </Style> \n"
324  << " <Style id=\"mag2 yellow\"> \n"
325  << " <IconStyle> \n"
326  << " <Icon> \n"
327  << " <href>data/star_3_yellow.png</href> \n"
328  << " </Icon> \n"
329  << " </IconStyle> \n"
330  << " </Style> \n"
331  << " <Style id=\"mag3 yellow\"> \n"
332  << " <IconStyle> \n"
333  << " <Icon> \n"
334  << " <href>data/star_4_yellow.png</href> \n"
335  << " </Icon> \n"
336  << " </IconStyle> \n"
337  << " </Style> \n"
338  << " <Style id=\"mag4 yellow\"> \n"
339  << " <IconStyle> \n"
340  << " <Icon> \n"
341  << " <href>data/star_5_yellow.png</href> \n"
342  << " </Icon> \n"
343  << " </IconStyle> \n"
344  << " </Style> \n"
345  << " <Style id=\"mag5 yellow\"> \n"
346  << " <IconStyle> \n"
347  << " <Icon> \n"
348  << " <href>data/star_6_yellow.png</href> \n"
349  << " </Icon> \n"
350  << " </IconStyle> \n"
351  << " </Style> \n"
352  << " <Style id=\"mag6 yellow\"> \n"
353  << " <IconStyle> \n"
354  << " <Icon> \n"
355  << " <href>data/star_7_yellow.png</href> \n"
356  << " </Icon> \n"
357  << " </IconStyle> \n"
358  << " </Style> \n"
359  << " <Style id=\"mag7 yellow\"> \n"
360  << " <IconStyle> \n"
361  << " <Icon> \n"
362  << " <href>data/star_8_yellow.png</href> \n"
363  << " </Icon> \n"
364  << " </IconStyle> \n"
365  << " </Style> \n"
366  << " <Style id=\"mag-1 orange\"> \n"
367  << " <IconStyle> \n"
368  << " <Icon> \n"
369  << " <href>data/star_0_orange.png</href> \n"
370  << " </Icon> \n"
371  << " </IconStyle> \n"
372  << " </Style> \n"
373  << " <Style id=\"mag0 orange\"> \n"
374  << " <IconStyle> \n"
375  << " <Icon> \n"
376  << " <href>data/star_1_orange.png</href> \n"
377  << " </Icon> \n"
378  << " </IconStyle> \n"
379  << " </Style> \n"
380  << " <Style id=\"mag1 orange\"> \n"
381  << " <IconStyle> \n"
382  << " <Icon> \n"
383  << " <href>data/star_2_orange.png</href> \n"
384  << " </Icon> \n"
385  << " </IconStyle> \n"
386  << " </Style> \n"
387  << " <Style id=\"mag2 orange\"> \n"
388  << " <IconStyle> \n"
389  << " <Icon> \n"
390  << " <href>data/star_3_orange.png</href> \n"
391  << " </Icon> \n"
392  << " </IconStyle> \n"
393  << " </Style> \n"
394  << " <Style id=\"mag3 orange\"> \n"
395  << " <IconStyle> \n"
396  << " <Icon> \n"
397  << " <href>data/star_4_orange.png</href> \n"
398  << " </Icon> \n"
399  << " </IconStyle> \n"
400  << " </Style> \n"
401  << " <Style id=\"mag4 orange\"> \n"
402  << " <IconStyle> \n"
403  << " <Icon> \n"
404  << " <href>data/star_5_orange.png</href> \n"
405  << " </Icon> \n"
406  << " </IconStyle> \n"
407  << " </Style> \n"
408  << " <Style id=\"mag5 orange\"> \n"
409  << " <IconStyle> \n"
410  << " <Icon> \n"
411  << " <href>data/star_6_orange.png</href> \n"
412  << " </Icon> \n"
413  << " </IconStyle> \n"
414  << " </Style> \n"
415  << " <Style id=\"mag6 orange\"> \n"
416  << " <IconStyle> \n"
417  << " <Icon> \n"
418  << " <href>data/star_7_orange.png</href> \n"
419  << " </Icon> \n"
420  << " </IconStyle> \n"
421  << " </Style> \n"
422  << " <Style id=\"mag7 orange\"> \n"
423  << " <IconStyle> \n"
424  << " <Icon> \n"
425  << " <href>data/star_8_orange.png</href> \n"
426  << " </Icon> \n"
427  << " </IconStyle> \n"
428  << " </Style> \n"
429  << " <Style id=\"mag-1 red\"> \n"
430  << " <IconStyle> \n"
431  << " <Icon> \n"
432  << " <href>data/star_0_red.png</href> \n"
433  << " </Icon> \n"
434  << " </IconStyle> \n"
435  << " </Style> \n"
436  << " <Style id=\"mag0 red\"> \n"
437  << " <IconStyle> \n"
438  << " <Icon> \n"
439  << " <href>data/star_1_red.png</href> \n"
440  << " </Icon> \n"
441  << " </IconStyle> \n"
442  << " </Style> \n"
443  << " <Style id=\"mag1 red\"> \n"
444  << " <IconStyle> \n"
445  << " <Icon> \n"
446  << " <href>data/star_2_red.png</href> \n"
447  << " </Icon> \n"
448  << " </IconStyle> \n"
449  << " </Style> \n"
450  << " <Style id=\"mag2 red\"> \n"
451  << " <IconStyle> \n"
452  << " <Icon> \n"
453  << " <href>data/star_3_red.png</href> \n"
454  << " </Icon> \n"
455  << " </IconStyle> \n"
456  << " </Style> \n"
457  << " <Style id=\"mag3 red\"> \n"
458  << " <IconStyle> \n"
459  << " <Icon> \n"
460  << " <href>data/star_4_red.png</href> \n"
461  << " </Icon> \n"
462  << " </IconStyle> \n"
463  << " </Style> \n"
464  << " <Style id=\"mag4 red\"> \n"
465  << " <IconStyle> \n"
466  << " <Icon> \n"
467  << " <href>data/star_5_red.png</href> \n"
468  << " </Icon> \n"
469  << " </IconStyle> \n"
470  << " </Style> \n"
471  << " <Style id=\"mag5 red\"> \n"
472  << " <IconStyle> \n"
473  << " <Icon> \n"
474  << " <href>data/star_6_red.png</href> \n"
475  << " </Icon> \n"
476  << " </IconStyle> \n"
477  << " </Style> \n"
478  << " <Style id=\"mag6 red\"> \n"
479  << " <IconStyle> \n"
480  << " <Icon> \n"
481  << " <href>data/star_7_red.png</href> \n"
482  << " </Icon> \n"
483  << " </IconStyle> \n"
484  << " </Style> \n"
485  << " <Style id=\"mag7 red\"> \n"
486  << " <IconStyle> \n"
487  << " <Icon> \n"
488  << " <href>data/star_8_red.png</href> \n"
489  << " </Icon> \n"
490  << " </IconStyle> \n"
491  << " </Style> \n"
492  << " <Style id=\"mag-1 garnetred\"> \n"
493  << " <IconStyle> \n"
494  << " <Icon> \n"
495  << " <href>data/star_0_garnetred.png</href> \n"
496  << " </Icon> \n"
497  << " </IconStyle> \n"
498  << " </Style> \n"
499  << " <Style id=\"mag0 garnetred\"> \n"
500  << " <IconStyle> \n"
501  << " <Icon> \n"
502  << " <href>data/star_1_garnetred.png</href> \n"
503  << " </Icon> \n"
504  << " </IconStyle> \n"
505  << " </Style> \n"
506  << " <Style id=\"mag1 garnetred\"> \n"
507  << " <IconStyle> \n"
508  << " <Icon> \n"
509  << " <href>data/star_2_garnetred.png</href> \n"
510  << " </Icon> \n"
511  << " </IconStyle> \n"
512  << " </Style> \n"
513  << " <Style id=\"mag2 garnetred\"> \n"
514  << " <IconStyle> \n"
515  << " <Icon> \n"
516  << " <href>data/star_3_garnetred.png</href> \n"
517  << " </Icon> \n"
518  << " </IconStyle> \n"
519  << " </Style> \n"
520  << " <Style id=\"mag3 garnetred\"> \n"
521  << " <IconStyle> \n"
522  << " <Icon> \n"
523  << " <href>data/star_4_garnetred.png</href> \n"
524  << " </Icon> \n"
525  << " </IconStyle> \n"
526  << " </Style> \n"
527  << " <Style id=\"mag4 garnetred\"> \n"
528  << " <IconStyle> \n"
529  << " <Icon> \n"
530  << " <href>data/star_5_garnetred.png</href> \n"
531  << " </Icon> \n"
532  << " </IconStyle> \n"
533  << " </Style> \n"
534  << " <Style id=\"mag5 garnetred\"> \n"
535  << " <IconStyle> \n"
536  << " <Icon> \n"
537  << " <href>data/star_6_garnetred.png</href> \n"
538  << " </Icon> \n"
539  << " </IconStyle> \n"
540  << " </Style> \n"
541  << " <Style id=\"mag6 garnetred\"> \n"
542  << " <IconStyle> \n"
543  << " <Icon> \n"
544  << " <href>data/star_7_garnetred.png</href> \n"
545  << " </Icon> \n"
546  << " </IconStyle> \n"
547  << " </Style> \n"
548  << " <Style id=\"mag7 garnetred\"> \n"
549  << " <IconStyle> \n"
550  << " <Icon> \n"
551  << " <href>data/star_8_garnetred.png</href> \n"
552  << " </Icon> \n"
553  << " </IconStyle> \n"
554  << " </Style> \n";
555 
556  QFile data("catalog.dat");
557  if ( data.open( QFile::ReadOnly ) ) {
558  QTextStream stream(&data);
559  QString line;
560  do {
561  line = stream.readLine();
562 
563  QString recString = line.mid( 75, 6 );
564  double raHH = recString.mid( 0, 2 ).toDouble();
565  double raMM = recString.mid( 2, 2 ).toDouble();
566  double raSS = recString.mid( 4, 2 ).toDouble();
567 
568  qreal longitude = ( raHH + raMM / 60.0 + raSS / 3600.0 ) * 15.0 - 180.0;
569 
570  QString decString = line.mid( 83, 7 );
571  double deSign = ( decString.mid( 0, 1 ) == "-" ) ? -1.0 : 1.0;
572  double deHH = decString.mid( 1, 2 ).toDouble();
573  double deMM = decString.mid( 3, 2 ).toDouble();
574  double deSS = decString.mid( 5, 2 ).toDouble();
575 
576  double deValue = deSign * ( deHH + deMM / 60.0 + deSS / 3600.0 );
577 
578  qreal latitude = deValue;
579 
580  QString magString = line.mid( 102, 5 );
581  double magValue = magString.toDouble();
582 
583  QString bvString = line.mid( 108, 6);
584  int colorIdx = 2; // Default White
585 
586  // Find Index of Table Entry with Closest B-V value (Smallest Difference)
587  if(bvString != QString(" ")) {
588  double bvValue = bvString.toDouble();
589  double bvMinDifference = fabs(colorTable.at(0)-bvValue);
590  for (int i = 1; i < colorTable.size(); ++i) {
591  double bvDifference = fabs(colorTable.at(i)-bvValue);
592  if (bvDifference < bvMinDifference) {
593  colorIdx = i;
594  bvMinDifference = bvDifference;
595  }
596  }
597  }
598 
599  QString styleId;
600  if ( magValue < -1 ) {
601  styleId = "mag-1";
602  }
603  else if ( magValue < 0 && magValue > -1 ) {
604  styleId = "mag0";
605  }
606  else if ( magValue < 1 && magValue > 0 ) {
607  styleId = "mag1";
608  }
609  else if ( magValue < 2 && magValue > 1 ) {
610  styleId = "mag2";
611  }
612  else if ( magValue < 3 && magValue > 2 ) {
613  styleId = "mag3";
614  }
615  else if ( magValue < 4 && magValue > 3 ) {
616  styleId = "mag4";
617  }
618  else if ( magValue < 5 && magValue > 4 ) {
619  styleId = "mag5";
620  }
621  else if ( magValue < 6 && magValue > 5 ) {
622  styleId = "mag6";
623  }
624  else {
625  styleId = "mag7";
626  }
627 
628  if ( colorIdx == 0 ) {
629  styleId += " blue";
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 ) {
637  styleId += " red";
638  } else if ( colorIdx == 6 ) {
639  styleId += " garnetred";
640  } else {
641  // white and no color ID
642  styleId += " white";
643  }
644 
645  out << " <Placemark> \n";
646 
647  QString name = line.mid( 7, 3 );
648  if ( name == "Alp" ) {
649  out << " <name>" << QString::fromUtf8( "α" ) << "</name> \n";
650  } else if ( name == "Bet" ) {
651  out << " <name>" << QString::fromUtf8( "β" ) << "</name> \n";
652  } else if ( name == "Gam" ) {
653  out << " <name>" << QString::fromUtf8( "γ" ) << "</name> \n";
654  } else if ( name == "Del" ) {
655  out << " <name>" << QString::fromUtf8( "δ" ) << "</name> \n";
656  } else if ( name == "Eps" ) {
657  out << " <name>" << QString::fromUtf8( "ε" ) << "</name> \n";
658  }
659 
660  out << " <styleUrl>#" << styleId << "</styleUrl> \n"
661  << " <Point> \n"
662  << " <coordinates>" << longitude << "," << latitude << ",0" << "</coordinates> \n"
663  << " </Point> \n"
664  << " </Placemark> \n";
665 
666  } while ( !line.isNull() );
667  }
668 
669  out << "</Document> \n"
670  << "</kml> \n";
671 
672  file.close();
673 }
674 
675 int main(int argc, char *argv[])
676 {
677  QCoreApplication app(argc, argv);
678 
679  if (!QFileInfo("catalog.dat").exists())
680  {
681  std::cerr << "Missing stars.dat in current directory. Exiting." << std::endl;
682  return 1;
683  }
684 
685  colorTable.append(double(-0.23)); // Spica blue
686  colorTable.append(double(0.0)); //Rigel blue-white
687  colorTable.append(double(0.09)); //Deneb white
688  colorTable.append(double(0.80)); //Capella yellow
689  colorTable.append(double(1.23)); //Arcturus orange
690  colorTable.append(double(1.85)); //Betelgeuse red
691  colorTable.append(double(2.35)); //Mu Cep garnet red
692 
693  exportToDat();
694  exportToKml();
695 
696  QFile starFile("stars.dat");
697  starFile.open(QIODevice::ReadOnly);
698  QDataStream in(&starFile); // read the data serialized from the file
699  // Read and check the header
700  quint32 magic;
701  in >> magic;
702  if (magic != 0x73746172)
703  return -1;
704 
705  // Read the version
706  qint32 version;
707  in >> version;
708  if (version > 004) {
709  qDebug() << "stars.dat: file too new.";
710  return -1;
711  }
712  int id;
713  double ra;
714  double de;
715  double mag;
716  int colorIdx;
717 
718  while ( !in.atEnd() ) {
719  in >> id;
720  in >> ra;
721  in >> de;
722  in >> mag;
723  in >> colorIdx;
724  qDebug() << "ID:" << id << "RA:" << ra << "DE:" << de << "MAG:" << mag << "idx:" << colorIdx;
725  }
726 
727  app.exit();
728 }
exportToKml
void exportToKml()
Definition: stars.cpp:105
QCoreApplication
M_PI
#define M_PI
Definition: GeoDataCoordinates.h:26
mag
double mag(double x[3])
Definition: sgp4ext.cpp:68
exportToDat
void exportToDat()
Definition: stars.cpp:28
colorTable
QVector< double > colorTable(0)
main
int main(int argc, char *argv[])
Definition: stars.cpp:675
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal