• 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
  • src
  • lib
  • marble
  • geodata
  • parser
GeoDataParser.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 
4  This file is part of the KDE project
5 
6  This library is free software you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  aint with this library see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 
23 // Own
24 #include "GeoDataParser.h"
25 
26 // Marble
27 #include "MarbleDebug.h"
28 
29 // Geodata
30 #include "GeoDataDocument.h"
31 #include "GeoDocument.h"
32 #include "GeoTagHandler.h"
33 
34 
35 // TODO: GeoRSS support
36 // #include "GeoRSSElementDictionary.h"
37 
38 // KML support
39 #include "KmlElementDictionary.h"
40 
41 namespace Marble
42 {
43 
44 GeoDataParser::GeoDataParser(GeoDataSourceType source)
45  : GeoParser(source)
46 {
47 }
48 
49 GeoDataParser::~GeoDataParser()
50 {
51 }
52 
53 bool GeoDataParser::isValidRootElement()
54 {
55  if (m_source == GeoData_UNKNOWN)
56  {
57  if (GeoParser::isValidElement(kml::kmlTag_kml))
58  {
59  m_source = GeoData_KML;
60  }
61  else
62  {
63  Q_ASSERT(false);
64  return false;
65  }
66  }
67  switch ((GeoDataSourceType) m_source) {
68  // TODO: case GeoData_GeoRSS:
69  case GeoData_KML:
70  return isValidElement(kml::kmlTag_kml);
71  default:
72  Q_ASSERT(false);
73  return false;
74  }
75 }
76 
77 bool GeoDataParser::isValidElement(const QString& tagName) const
78 {
79  if (!GeoParser::isValidElement(tagName))
80  return false;
81 
82  switch ((GeoDataSourceType) m_source) {
83  // TODO: case GeoData_GeoRSS:
84  case GeoData_KML:
85  return (namespaceUri() == kml::kmlTag_nameSpace20 ||
86  namespaceUri() == kml::kmlTag_nameSpace21 ||
87  namespaceUri() == kml::kmlTag_nameSpace22 ||
88  namespaceUri() == kml::kmlTag_nameSpaceOgc22 ||
89  namespaceUri() == kml::kmlTag_nameSpaceGx22);
90  default:
91  break;
92  }
93 
94  // Should never be reached.
95  Q_ASSERT(false);
96  return false;
97 }
98 
99 GeoDocument* GeoDataParser::createDocument() const
100 {
101  return new GeoDataDocument;
102 }
103 
104 // Global helper function for the tag handlers
105 GeoDataDocument* geoDataDoc(GeoParser& parser)
106 {
107  GeoDocument* document = parser.activeDocument();
108  Q_ASSERT(document->isGeoDataDocument());
109  return static_cast<GeoDataDocument*>(document);
110 }
111 
112 }
GeoDataDocument.h
Marble::GeoParser::activeDocument
GeoDocument * activeDocument()
Definition: GeoParser.h:62
Marble::kml::kmlTag_nameSpaceGx22
const char * kmlTag_nameSpaceGx22
Definition: KmlElementDictionary.cpp:35
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::GeoParser::m_source
GeoDataGenericSourceType m_source
Definition: GeoParser.h:90
QXmlStreamReader::namespaceUri
QStringRef namespaceUri() const
GeoTagHandler.h
GeoDataParser.h
Marble::kml::kmlTag_nameSpace22
const char * kmlTag_nameSpace22
Definition: KmlElementDictionary.cpp:33
MarbleDebug.h
Marble::GeoParser
Definition: GeoParser.h:40
Marble::GeoData_KML
Definition: GeoDataParser.h:36
Marble::GeoDataParser::GeoDataParser
GeoDataParser(GeoDataSourceType source)
Definition: GeoDataParser.cpp:44
KmlElementDictionary.h
GeoDocument.h
Marble::GeoDataParser::~GeoDataParser
virtual ~GeoDataParser()
Definition: GeoDataParser.cpp:49
QString
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoParser::isValidElement
virtual bool isValidElement(const QString &tagName) const
Definition: GeoParser.cpp:117
Marble::GeoData_UNKNOWN
Definition: GeoDataParser.h:35
Marble::kml::kmlTag_nameSpace21
const char * kmlTag_nameSpace21
Definition: KmlElementDictionary.cpp:32
Marble::GeoDocument
A shared base class between GeoDataDocument/GeoSourceDocument.
Definition: GeoDocument.h:42
Marble::kml::kmlTag_nameSpace20
const char * kmlTag_nameSpace20
Definition: KmlElementDictionary.cpp:31
Marble::GeoDocument::isGeoDataDocument
virtual bool isGeoDataDocument() const
Definition: GeoDocument.cpp:49
Marble::GeoDataSourceType
GeoDataSourceType
Definition: GeoDataParser.h:34
Marble::kml::kmlTag_kml
const char * kmlTag_kml
Definition: KmlElementDictionary.cpp:91
Marble::geoDataDoc
GeoDataDocument * geoDataDoc(GeoParser &parser)
Definition: GeoDataParser.cpp:105
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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