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 "DgmlElementDictionary.h"
16#include "DgmlAttributeDictionary.h"
17#include "DgmlAuxillaryDictionary.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(QLatin1String(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 )
48 && parentItem.nodeAs<GeoSceneLayer>()->backend() == dgmlValue_vectortile ) {
49
50 texture = new GeoSceneVectorTileDataset( name );
51 texture->setExpire( expire );
52 parentItem.nodeAs<GeoSceneLayer>()->addDataset( texture );
53 }
54
55 return texture;
56}
57
58}
59}
60
QString name(StandardShortcut id)
Binds a QML item to a specific geodetic location in screen coordinates.
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 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.