• 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/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-2012 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( QDataStream * out, const QString & path, int header )
17  : m_stream(out),
18  m_header(header),
19  m_path(path)
20 {
21 }
22 
23 bool SVGXmlHandler::startElement(const QString& nspace,
24  const QString& localName,
25  const QString& qName,
26  const QXmlAttributes &atts)
27 {
28  if ( qName == "path" && atts.value( "id" ) == m_path ) {
29  QString coordinates = atts.value( "d" );
30 
31  QStringList stringlist;
32  coordinates.chop(2);
33 
34  // This requires absolute paths and repeated L commands to
35  // to be enforced in inkscape!
36  stringlist << coordinates.mid( 1 ).split( 'L' );
37  bool firstheader = true;
38 
39  int count = 0;
40  qDebug() << "Starting to write path" << atts.value( "id" );
41  foreach ( const QString& str, stringlist ) {
42  float x;
43  float y;
44  x = str.section( ',', 0, 0 ).toFloat();
45  y = str.section( ',', 1, 1 ).toFloat();
46 
47  short header;
48  short lat;
49  short lng;
50 
51  if ( firstheader ) {
52  header = m_header;
53  firstheader = false;
54  }
55  else {
56  if ( stringlist.size() > 14 ) {
57  if ( count % 9 == 0 )
58  header = 5;
59  else if ( count % 5 == 0 )
60  header = 3;
61  else if ( count % 2 == 0 )
62  header = 2;
63  else
64  header = 1;
65  }
66  else if ( stringlist.size() > 6 ) {
67  if ( count % 2 == 0 )
68  header = 3;
69  else
70  header = 1;
71  }
72  else {
73  header = 2;
74  }
75  }
76  if ( count == stringlist.size() - 1 )
77  header = 5;
78 
79  lng = (int)( x * 50 - 10800 );
80  lat = -(int)( y * 50 - 5400 );
81 
82  *m_stream << header << lat << lng;
83  count++;
84  }
85  }
86 
87  return true;
88 }
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