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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • tools
  • pntdel
pntdel.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 2012 Torsten Rahn <tackat@kde.org>
9 //
10 
11 
12 #include <QCoreApplication>
13 #include <QDataStream>
14 #include <QFile>
15 #include <QDebug>
16 #include <QStringList>
17 
18 int main(int argc, char *argv[])
19 {
20  QCoreApplication app(argc, argv);
21 
22  qDebug( " Syntax: pntdel [-i pnt-sourcefile -o pnt-targetfile -id idNumber] " );
23 
24  QString inputFilename("PDIFFBORDERS.PNT");
25  int inputIndex = app.arguments().indexOf("-i");
26  if (inputIndex > 0 && inputIndex + 1 < argc )
27  inputFilename = app.arguments().at( inputIndex + 1 );
28 
29  QString outputFilename("NEW.PNT");
30  int outputIndex = app.arguments().indexOf("-o");
31  if (outputIndex > 0 && outputIndex + 1 < argc )
32  outputFilename = app.arguments().at( outputIndex + 1 );
33 
34  int delIndex = -1;
35  int idIndex = app.arguments().indexOf("-id");
36  if (idIndex > 0 && idIndex + 1 < argc )
37  delIndex = app.arguments().at( idIndex + 1 ).toInt();
38 
39 
40  qDebug() << "input filename:" << inputFilename;
41  qDebug() << "output filename:" << outputFilename;
42  qDebug() << "remove index:" << delIndex;
43 
44  // INPUT
45  QFile file( inputFilename );
46 
47  if ( file.open( QIODevice::ReadOnly ) ) {
48  QDataStream stream( &file ); // read the data serialized from the file
49  stream.setByteOrder( QDataStream::LittleEndian );
50 
51  // OUTPUT
52  QFile data(outputFilename);
53 
54  if (data.open(QFile::WriteOnly | QFile::Truncate)) {
55  QDataStream out(&data);
56  out.setByteOrder( QDataStream::LittleEndian );
57 
58  short header;
59  short iLat;
60  short iLon;
61 
62  bool skip = false;
63 
64  while( !stream.atEnd() ){
65  stream >> header >> iLat >> iLon;
66  if ( header == delIndex ) {
67  skip = true;
68  }
69  else if ( header > 5 )
70  skip = false;
71 
72  if ( !skip )
73  out << header << iLat << iLon;
74  }
75  data.close();
76  }
77  else {
78  qDebug() << "ERROR: Couldn't write output file to disc!";
79  }
80  file.close();
81  }
82  else {
83  qDebug() << "ERROR: Source file not found!";
84  }
85 
86  app.exit();
87 }
QDataStream
QCoreApplication
QList::at
const T & at(int i) const
QFile
QCoreApplication::exit
void exit(int returnCode)
QString
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QDataStream::atEnd
bool atEnd() const
QFile::close
virtual void close()
QDataStream::setByteOrder
void setByteOrder(ByteOrder bo)
QStringList::indexOf
int indexOf(const QRegExp &rx, int from) const
main
int main(int argc, char *argv[])
Definition: pntdel.cpp:18
QCoreApplication::arguments
QStringList arguments()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 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
  • 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