Marble

DgmlVectorTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "DgmlVectorTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "DgmlElementDictionary.h"
12 #include "DgmlAttributeDictionary.h"
13 #include "DgmlAuxillaryDictionary.h"
14 #include "GeoParser.h"
15 #include "GeoSceneLayer.h"
16 #include "GeoSceneGeodata.h"
17 
18 namespace Marble
19 {
20 namespace dgml
21 {
22 DGML_DEFINE_TAG_HANDLER(Vector)
23 
24 GeoNode* DgmlVectorTagHandler::parse(GeoParser& parser) const
25 {
26  // Check whether the tag is valid
27  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Vector)));
28 
29  QString name = parser.attribute(dgmlAttr_name).trimmed();
30  QString feature = parser.attribute(dgmlAttr_feature).trimmed();
31 
32  GeoSceneGeodata *vector = nullptr;
33 
34  // Checking for parent item
35  GeoStackItem parentItem = parser.parentElement();
36 
37  // Check parent type and make sure that the dataSet type
38  // matches the backend of the parent layer
39  if ( parentItem.represents(dgmlTag_Layer)
40  && parentItem.nodeAs<GeoSceneLayer>()->backend() == dgmlValue_vector ) {
41 
42  vector = new GeoSceneGeodata( name );
43  vector->setProperty( feature );
44  vector->setColorize( feature );
45  parentItem.nodeAs<GeoSceneLayer>()->addDataset( vector );
46  }
47 
48  return vector;
49 }
50 
51 }
52 }
QString trimmed() 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.