Marble

KmlAltitudeModeTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
3  SPDX-FileCopyrightText: 2009 Bastian Holst <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "KmlAltitudeModeTagHandler.h"
9 
10 #include "MarbleDebug.h"
11 
12 #include "KmlElementDictionary.h"
13 
14 #include "GeoDataGeometry.h"
15 #include "GeoDataLatLonAltBox.h"
16 #include "GeoDataGroundOverlay.h"
17 #include "GeoDataPoint.h"
18 #include "GeoDataPlacemark.h"
19 #include "GeoDataTrack.h"
20 #include "GeoDataAbstractView.h"
21 #include "GeoDataModel.h"
22 
23 #include "GeoParser.h"
24 
25 namespace Marble
26 {
27 namespace kml
28 {
29 KML_DEFINE_TAG_HANDLER( altitudeMode )
30 
31 GeoNode* KmlaltitudeModeTagHandler::parse( GeoParser& parser ) const
32 {
33  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_altitudeMode)));
34 
35  QString content = parser.readElementText().trimmed();
36 
37  AltitudeMode mode;
38  if (content == QLatin1String("relativeToGround")) {
39  mode = RelativeToGround;
40  } else if (content == QLatin1String("absolute")) {
41  mode = Absolute;
42  } else { // clampToGround is Standard
43  mode = ClampToGround;
44  }
45 
46  GeoStackItem parentItem = parser.parentElement();
47 
48  if ( parentItem.is<GeoDataPlacemark>() ) {
49  parentItem.nodeAs<GeoDataPlacemark>()->geometry()->setAltitudeMode( mode );
50  } else if ( parentItem.is<GeoDataPoint>() ) {
51  parentItem.nodeAs<GeoDataPoint>()->setAltitudeMode( mode );
52  } else if ( parentItem.is<GeoDataLatLonAltBox>() ) {
53  parentItem.nodeAs<GeoDataLatLonAltBox>()->setAltitudeMode( mode );
54  } else if ( parentItem.is<GeoDataTrack>() ) {
55  parentItem.nodeAs<GeoDataTrack>()->setAltitudeMode( mode );
56  } else if ( parentItem.is<GeoDataGroundOverlay>() ) {
57  parentItem.nodeAs<GeoDataGroundOverlay>()->setAltitudeMode( mode );
58  } else if ( parentItem.is<GeoDataAbstractView>() ) {
59  parentItem.nodeAs<GeoDataAbstractView>()->setAltitudeMode( mode );
60  } else if ( parentItem.is<GeoDataModel>() ) {
61  parentItem.nodeAs<GeoDataModel>()->setAltitudeMode( mode );
62  }
63 
64  return nullptr;
65 }
66 
67 }
68 }
QString trimmed() const const
Binds a QML item to a specific geodetic location in screen coordinates.
@ Absolute
Altitude is given relative to the sealevel.
Definition: MarbleGlobal.h:134
@ ClampToGround
Altitude always sticks to ground level.
Definition: MarbleGlobal.h:132
@ RelativeToGround
Altitude is always given relative to ground level.
Definition: MarbleGlobal.h:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.