Marble

DgmlVectortileTagHandler.cpp
1 /*
2  SPDX-License-Identifier: LGPL-2.1-or-later
3 
4  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
5 
6  SPDX-FileCopyrightText: 2012 Ander Pijoan <[email protected]>
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 
22 namespace Marble
23 {
24 namespace dgml
25 {
26 DGML_DEFINE_TAG_HANDLER(Vectortile)
27 
28 GeoNode* 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 trimmed() const const
bool isEmpty() const const
int toInt(bool *ok, int base) const const
Binds a QML item to a specific geodetic location in screen coordinates.
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.