Marble

GeoDataParser.cpp
1/*
2 SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7
8// Own
9#include "GeoDataParser.h"
10
11// Marble
12#include "MarbleDebug.h"
13
14// Geodata
15#include "GeoDataDocument.h"
16#include "GeoDocument.h"
17#include "GeoTagHandler.h"
18
19
20// TODO: GeoRSS support
21// #include "GeoRSSElementDictionary.h"
22
23// KML support
24#include "KmlElementDictionary.h"
25
26namespace Marble
27{
28
29GeoDataParser::GeoDataParser(GeoDataSourceType source)
30 : GeoParser(source)
31{
32}
33
34GeoDataParser::~GeoDataParser()
35{
36}
37
38bool GeoDataParser::isValidRootElement()
39{
40 if (m_source == GeoData_UNKNOWN)
41 {
42 if (GeoParser::isValidElement(kml::kmlTag_kml))
43 {
44 m_source = GeoData_KML;
45 }
46 else
47 {
48 Q_ASSERT(false);
49 return false;
50 }
51 }
52 switch ((GeoDataSourceType) m_source) {
53 // TODO: case GeoData_GeoRSS:
54 case GeoData_KML:
55 return isValidElement(kml::kmlTag_kml);
56 default:
57 Q_ASSERT(false);
58 return false;
59 }
60}
61
62bool GeoDataParser::isValidElement(const QString& tagName) const
63{
64 if (!GeoParser::isValidElement(tagName))
65 return false;
66
67 switch ((GeoDataSourceType) m_source) {
68 // TODO: case GeoData_GeoRSS:
69 case GeoData_KML: {
70 const QStringRef namespaceUri = this->namespaceUri();
71 return (namespaceUri == QLatin1String(kml::kmlTag_nameSpace20) ||
72 namespaceUri == QLatin1String(kml::kmlTag_nameSpace21) ||
73 namespaceUri == QLatin1String(kml::kmlTag_nameSpace22) ||
74 namespaceUri == QLatin1String(kml::kmlTag_nameSpaceOgc22) ||
75 namespaceUri == QLatin1String(kml::kmlTag_nameSpaceGx22) ||
76 namespaceUri == QLatin1String(kml::kmlTag_nameSpaceMx));
77 }
78 default:
79 break;
80 }
81
82 // Should never be reached.
83 Q_ASSERT(false);
84 return false;
85}
86
87GeoDocument* GeoDataParser::createDocument() const
88{
89 return new GeoDataDocument;
90}
91
92// Global helper function for the tag handlers
93GeoDataDocument* geoDataDoc(GeoParser& parser)
94{
95 GeoDocument* document = parser.activeDocument();
96 Q_ASSERT(document->isGeoDataDocument());
97 return static_cast<GeoDataDocument*>(document);
98}
99
100}
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.