• 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
  • dso2kml
dso2kml.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 2013 Mohammed Nafees <nafees.technocool@gmail.com>
9 //
10 
11 
12 #include <QFile>
13 #include <QDebug>
14 #include <QApplication>
15 #include <QStringList>
16 
17 #include <cmath>
18 #include <iostream>
19 
20 int main(int argc, char *argv[])
21 {
22  QCoreApplication app(argc, argv);
23 
24  QFile dsoData( "dso.dat" );
25  if ( !dsoData.open( QFile::ReadOnly ) ) {
26  std::cout << "File dso.dat not found in current path. Exiting." << std::endl;
27  return 1;
28  }
29 
30  QFile file( "dso.kml" );
31  file.open( QIODevice::WriteOnly );
32  QTextStream out( &file );
33 
34  out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
35  << "<kml xmlns=\"http://earth.google.com/kml/2.2\" hint=\"target=sky\"> \n"
36  << "<Document> \n"
37  << " <Style id=\"iconStyle\"> \n"
38  << " <IconStyle> \n"
39  << " <Icon> \n"
40  << " <href>deepsky.png</href> \n"
41  << " </Icon> \n"
42  << " </IconStyle> \n"
43  << " </Style> \n";
44 
45  QTextStream in( &dsoData );
46 
47  QString line;
48  qreal longitude;
49  qreal latitude;
50 
51  while ( !in.atEnd() ) {
52  line = in.readLine();
53 
54  // Check for null line at end of file
55  if ( line.isNull() ) {
56  continue;
57  }
58 
59  // Ignore Comment lines in header and
60  // between dso entries
61  if ( line.startsWith( '#' ) ) {
62  continue;
63  }
64 
65  QStringList entries = line.split( QLatin1Char( ',' ) );
66 
67  QString id = entries.at( 0 );
68  QString longName = entries.at(7);
69 
70  double raH = entries.at( 1 ).toDouble();
71  double raM = entries.at( 2 ).toDouble();
72  double raS = entries.at( 3 ).toDouble();
73  double decH = entries.at( 4 ).toDouble();
74  double decM = entries.at( 5 ).toDouble();
75  double decS = entries.at( 6 ).toDouble();
76 
77  double ra = ( raH + raM / 60.0 + raS / 3600.0 ) * 15.0;
78  double dec;
79 
80  if ( decH >= 0.0 ) {
81  dec = decH + decM /60.0 + decS / 3600.0;
82  }
83  else {
84  dec = decH - decM / 60.0 - decS / 3600.0;
85  }
86 
87  longitude = ra - 180.0;
88  latitude = dec;
89 
90  out << " <Placemark> \n"
91  << " <name>" << id << "</name> \n"
92  << " <description>" << longName << "</description> \n"
93  << " <styleUrl>#iconStyle</styleUrl> \n"
94  << " <Point> \n"
95  << " <coordinates>" << longitude << "," << latitude << "</coordinates> \n"
96  << " </Point> \n"
97  << " </Placemark> \n";
98  }
99 
100  out << "</Document> \n"
101  << "</kml> \n";
102 
103  dsoData.close();
104  file.close();
105 
106  app.exit();
107 }
108 
109 
QCoreApplication
main
int main(int argc, char *argv[])
Definition: dso2kml.cpp:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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