Marble

DgmlVectortileTagHandler.cpp
1/*
2 SPDX-License-Identifier: LGPL-2.1-or-later
3
4 SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <zimmermann@kde.org>
5
6 SPDX-FileCopyrightText: 2012 Ander Pijoan <ander.pijoan@deusto.es>
7*/
8
9#include "DgmlVectortileTagHandler.h"
10
11#include <limits>
12
13#include "MarbleDebug.h"
14
15#include "DgmlAttributeDictionary.h"
16#include "DgmlAuxillaryDictionary.h"
17#include "DgmlElementDictionary.h"
18#include "GeoParser.h"
19#include "GeoSceneLayer.h"
20#include "GeoSceneVectorTileDataset.h"
21
22namespace Marble
23{
24namespace dgml
25{
26DGML_DEFINE_TAG_HANDLER(Vectortile)
27
28GeoNode *DgmlVectortileTagHandler::parse(GeoParser &parser) const
29{
30 // Check whether the tag is valid
31 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_Vectortile)));
32
33 const QString name = parser.attribute(dgmlAttr_name).trimmed();
34
35 const QString expireStr = parser.attribute(dgmlAttr_expire).trimmed();
36 int expire = std::numeric_limits<int>::max();
37 if (!expireStr.isEmpty())
38 expire = expireStr.toInt();
39
40 GeoSceneTileDataset *texture = nullptr;
41
42 // Checking for parent item
43 GeoStackItem parentItem = parser.parentElement();
44
45 // Check parent type and make sure that the dataSet type
46 // matches the backend of the parent layer
47 if (parentItem.represents(dgmlTag_Layer) && parentItem.nodeAs<GeoSceneLayer>()->backend() == QString::fromLatin1(dgmlValue_vectortile)) {
48 texture = new GeoSceneVectorTileDataset(name);
49 texture->setExpire(expire);
50 parentItem.nodeAs<GeoSceneLayer>()->addDataset(texture);
51 }
52
53 return texture;
54}
55
56}
57}
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.