• 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
  • svg2pnt
svg2pnt/svgxmlhandler.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 //
11 
12 
13 #include "svgxmlhandler.h"
14 #include <QDebug>
15 
16 SVGXmlHandler::SVGXmlHandler(const QString& targetfile)
17 {
18  m_header = 8000;
19  m_pointnum = 0;
20  m_initialized = false;
21  m_targetfile = targetfile;
22 }
23 
24 bool SVGXmlHandler::startElement(const QString& nspace,
25  const QString& localName,
26  const QString& qName,
27  const QXmlAttributes &atts)
28 {
29  qDebug();
30  if ( qName == "g" ) {
31  qDebug( "Parsing Data ..." );
32  m_initialized = true;
33  }
34 
35  if ( qName == "path" && m_initialized ) {
36  QString coordinates = atts.value( "d" );
37 
38  QStringList stringlist;
39  coordinates.chop(2);
40  stringlist << coordinates.mid( 1 ).split( 'L' );
41  // The last element is the first element
42  // stringlist.removeLast();
43  bool firstheader = true;
44  QFile file( m_targetfile );
45 
46  // Read the data serialized from the file.
47  file.open( QIODevice::Append );
48  QDataStream stream( &file );
49  stream.setByteOrder( QDataStream::LittleEndian );
50 
51  int count = 0;
52  qDebug() << "Starting to write path" << atts.value( "id" );
53  foreach ( const QString& str, stringlist ) {
54  // qDebug()<<str;
55  float x;
56  float y;
57  x = str.section( ',', 0, 0 ).toFloat();
58  y = str.section( ',', 1, 1 ).toFloat();
59 
60  // qDebug() << "x:" << x << "y:" << y;
61 
62  short header;
63  short lat;
64  short lng;
65 
66  if ( firstheader ) {
67  header = m_header;
68  firstheader = false;
69  }
70  else {
71  if ( stringlist.size() > 14 ) {
72  if ( count % 9 == 0 )
73  header = 5;
74  else if ( count % 5 == 0 )
75  header = 3;
76  else if ( count % 2 == 0 )
77  header = 2;
78  else
79  header = 1;
80  }
81  else if ( stringlist.size() > 6 ) {
82  if ( count % 2 == 0 )
83  header = 3;
84  else
85  header = 1;
86  }
87  else {
88  header = 2;
89  }
90  }
91  if ( count == stringlist.size() - 1 )
92  header = 5;
93 
94  lng = (int)( x * 50 - 10800 );
95  lat = -(int)( y * 50 - 5400 );
96 
97  qDebug() << "lng:" << lng << "lat:" << lat << "header:"
98  << header << "node#:" << m_pointnum;
99 
100  stream << header << lat << lng;
101  m_pointnum++;
102  count++;
103  }
104 
105  m_header++;
106  }
107 
108  return true;
109 }
SVGXmlHandler::SVGXmlHandler
SVGXmlHandler(QDataStream *out, const QString &path, int header)
Definition: pntreplace/svgxmlhandler.cpp:16
SVGXmlHandler::startElement
virtual bool startElement(const QString &, const QString &, const QString &, const QXmlAttributes &)
Definition: pntreplace/svgxmlhandler.cpp:23
svgxmlhandler.h
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