• 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
  • pntreplace
pntreplace.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 <QApplication>
13 #include <QDataStream>
14 #include <QFile>
15 #include <QDebug>
16 #include <QXmlInputSource>
17 #include <QXmlSimpleReader>
18 #include <QStringList>
19 #include "svgxmlhandler.h"
20 
21 void parseSvg( const QString & svgFilename, QDataStream * out, const QString & path, int header ) {
22 
23  SVGXmlHandler handler( out, path, header );
24  QFile xmlFile( svgFilename );
25  QXmlInputSource inputSource(&xmlFile);
26  QXmlSimpleReader reader;
27 
28  reader.setContentHandler(&handler);
29  reader.parse( inputSource );
30 }
31 
32 int main(int argc, char *argv[])
33 {
34  QApplication app(argc, argv);
35 
36  qDebug( " Syntax: pntreplace [-i pnt-sourcefile -o pnt-targetfile -s svg-replacementfile -id pntidNumber -path svgpathid] " );
37 
38  QString inputFilename("PDIFFBORDERS.PNT");
39  int inputIndex = app.arguments().indexOf("-i");
40  if (inputIndex > 0 && inputIndex + 1 < argc )
41  inputFilename = app.arguments().at( inputIndex + 1 );
42 
43  QString outputFilename("NEW.PNT");
44  int outputIndex = app.arguments().indexOf("-o");
45  if (outputIndex > 0 && outputIndex + 1 < argc )
46  outputFilename = app.arguments().at( outputIndex + 1 );
47 
48  QString svgFilename("output.svg");
49  int svgIndex = app.arguments().indexOf("-s");
50  if (svgIndex > 0 && svgIndex + 1 < argc )
51  svgFilename = app.arguments().at( svgIndex + 1 );
52 
53  QString path("id_path");
54  int pathIndex = app.arguments().indexOf("-path");
55  if (pathIndex > 0 && pathIndex + 1 < argc )
56  path = app.arguments().at( pathIndex + 1 );
57 
58  int delIndex = -1;
59  int idIndex = app.arguments().indexOf("-id");
60  if (idIndex > 0 && idIndex + 1 < argc )
61  delIndex = app.arguments().at( idIndex + 1 ).toInt();
62 
63 
64  qDebug() << "input filename:" << inputFilename;
65  qDebug() << "output filename:" << outputFilename;
66  qDebug() << "svg replacement filename:" << svgFilename;
67  qDebug() << "replace index:" << delIndex;
68  qDebug() << "replacement:" << path;
69 
70  // INPUT
71  QFile file( inputFilename );
72 
73  if ( file.open( QIODevice::ReadOnly ) ) {
74  QDataStream stream( &file ); // read the data serialized from the file
75  stream.setByteOrder( QDataStream::LittleEndian );
76 
77  // OUTPUT
78  QFile data(outputFilename);
79 
80  if (data.open(QFile::WriteOnly | QFile::Truncate)) {
81  QDataStream out(&data);
82  out.setByteOrder( QDataStream::LittleEndian );
83 
84  short header;
85  short iLat;
86  short iLon;
87 
88  bool skip = false;
89 
90  while( !stream.atEnd() ){
91  stream >> header >> iLat >> iLon;
92  if ( header == delIndex ) {
93  parseSvg( svgFilename, &out, path, delIndex );
94  skip = true;
95  }
96  else if ( header > 5 )
97  skip = false;
98 
99  if ( !skip )
100  out << header << iLat << iLon;
101  }
102  data.close();
103  }
104  else {
105  qDebug() << "ERROR: Couldn't write output file to disc!";
106  }
107  file.close();
108  }
109  else {
110  qDebug() << "ERROR: Source file not found!";
111  }
112 
113  app.exit();
114 }
Marble::dgml::handler
static GeoTagHandlerRegistrar handler(GeoParser::QualifiedName(dgmlTag_DownloadPolicy, dgmlTag_nameSpace20), new DgmlDownloadPolicyTagHandler)
parseSvg
void parseSvg(const QString &svgFilename, QDataStream *out, const QString &path, int header)
Definition: pntreplace.cpp:21
main
int main(int argc, char *argv[])
Definition: pntreplace.cpp:32
svgxmlhandler.h
SVGXmlHandler
Definition: pntreplace/svgxmlhandler.h:22
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 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