Marble

DgmlGeodataTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "DgmlGeodataTagHandler.h"
8
9#include <limits>
10
11#include "MarbleDebug.h"
12
13#include "DgmlAttributeDictionary.h"
14#include "DgmlAuxillaryDictionary.h"
15#include "DgmlElementDictionary.h"
16#include "GeoParser.h"
17#include "GeoSceneDocument.h"
18#include "GeoSceneGeodata.h"
19#include "GeoSceneLayer.h"
20#include "GeoSceneSettings.h"
21
22namespace Marble
23{
24namespace dgml
25{
26
27DGML_DEFINE_TAG_HANDLER(Geodata)
28
29GeoNode *DgmlGeodataTagHandler::parse(GeoParser &parser) const
30{
31 // Check whether the tag is valid
32 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_Geodata)));
33
34 const QString name = parser.attribute(dgmlAttr_name).trimmed();
35
36 const QString property = parser.attribute(dgmlAttr_property).trimmed();
37
38 const QString colorize = parser.attribute(dgmlAttr_colorize).trimmed();
39
40 const QString expireStr = parser.attribute(dgmlAttr_expire).trimmed();
41 int expire = std::numeric_limits<int>::max();
42 if (!expireStr.isEmpty())
43 expire = expireStr.toInt();
44
45 GeoSceneGeodata *dataSource = nullptr;
46
47 // Checking for parent item
48 GeoStackItem parentItem = parser.parentElement();
49
50 // Check parent type and make sure that the dataSet type
51 // matches the backend of the parent layer
52 if (parentItem.represents(dgmlTag_Layer) && parentItem.nodeAs<GeoSceneLayer>()->backend() == QString::fromLatin1(dgmlValue_geodata)) {
53 dataSource = new GeoSceneGeodata(name);
54 dataSource->setProperty(property);
55 dataSource->setColorize(colorize);
56 dataSource->setExpire(expire);
57 parentItem.nodeAs<GeoSceneLayer>()->addDataset(dataSource);
58 }
59
60 return dataSource;
61}
62
63}
64}
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
int toInt(bool *ok, int base) const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.