Marble

DgmlGeodataTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
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 "DgmlElementDictionary.h"
14 #include "DgmlAttributeDictionary.h"
15 #include "DgmlAuxillaryDictionary.h"
16 #include "GeoParser.h"
17 #include "GeoSceneDocument.h"
18 #include "GeoSceneLayer.h"
19 #include "GeoSceneSettings.h"
20 #include "GeoSceneGeodata.h"
21 
22 namespace Marble
23 {
24 namespace dgml
25 {
26 
27 DGML_DEFINE_TAG_HANDLER(Geodata)
28 
29 GeoNode* DgmlGeodataTagHandler::parse(GeoParser& parser) const
30 {
31  // Check whether the tag is valid
32  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(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)
53  && parentItem.nodeAs<GeoSceneLayer>()->backend() == dgmlValue_geodata) {
54  dataSource = new GeoSceneGeodata( name );
55  dataSource->setProperty( property );
56  dataSource->setColorize( colorize );
57  dataSource->setExpire( expire );
58  parentItem.nodeAs<GeoSceneLayer>()->addDataset( dataSource );
59  }
60 
61  return dataSource;
62 }
63 
64 }
65 }
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.
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.