Marble

KmlHeadingTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "KmlHeadingTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "KmlElementDictionary.h"
12 #include "GeoDataIconStyle.h"
13 #include "GeoDataCamera.h"
14 #include "GeoDataOrientation.h"
15 #include "GeoParser.h"
16 
17 namespace Marble
18 {
19 namespace kml
20 {
21 KML_DEFINE_TAG_HANDLER( heading )
22 
23 GeoNode* KmlheadingTagHandler::parse( GeoParser& parser ) const
24 {
25  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_heading)));
26 
27  GeoStackItem parentItem = parser.parentElement();
28 
29  int const heading = parser.readElementText().toInt();
30  if ( heading >= 0 && heading <= 360 ) {
31  if ( parentItem.represents( kmlTag_IconStyle ) ) {
32  parentItem.nodeAs<GeoDataIconStyle>()->setHeading( heading );
33  } else if ( parentItem.represents( kmlTag_Camera ) ) {
34  parentItem.nodeAs<GeoDataCamera>()->setHeading( heading );
35  } else if ( parentItem.represents( kmlTag_Orientation ) ) {
36  parentItem.nodeAs<GeoDataOrientation>()->setHeading( heading );
37  }
38  } else {
39  mDebug() << "Invalid heading value " << heading << ", must be within 0..360. Using 0 instead.";
40  }
41 
42  return nullptr;
43 }
44 
45 }
46 }
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.