Marble

KmlGxAltitudeModeTagHandler.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <[email protected]>
4 //
5 
6 
7 #include "KmlGxAltitudeModeTagHandler.h"
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 namespace gx
30 {
31 KML_DEFINE_TAG_HANDLER_GX22( altitudeMode )
32 
33 GeoNode* KmlaltitudeModeTagHandler::parse( GeoParser& parser ) const
34 {
35  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_altitudeMode)));
36 
37  QString content = parser.readElementText().trimmed();
38 
39  AltitudeMode mode;
40  if (content == QLatin1String("relativeToGround")) {
41  mode = RelativeToGround;
42  } else if (content == QLatin1String("absolute")) {
43  mode = Absolute;
44  } else if (content == QLatin1String("relativeToSeaFloor")) {
45  mode = RelativeToSeaFloor;
46  } else if (content == QLatin1String("clampToSeaFloor")) {
47  mode = ClampToSeaFloor;
48  } else if (content == QLatin1String("clampToGround")) {
49  mode = ClampToGround;
50  } else {
51  mDebug() << "Unknown altitude mode " << content << ", falling back to 'clampToGround'";
52  mode = ClampToGround;
53  }
54 
55  GeoStackItem parentItem = parser.parentElement();
56 
57  if ( parentItem.is<GeoDataPlacemark>() ) {
58  parentItem.nodeAs<GeoDataPlacemark>()->geometry()->setAltitudeMode( mode );
59  } else if ( parentItem.is<GeoDataPoint>() ) {
60  parentItem.nodeAs<GeoDataPoint>()->setAltitudeMode( mode );
61  } else if ( parentItem.is<GeoDataLatLonAltBox>() ) {
62  parentItem.nodeAs<GeoDataLatLonAltBox>()->setAltitudeMode( mode );
63  } else if ( parentItem.is<GeoDataTrack>() ) {
64  parentItem.nodeAs<GeoDataTrack>()->setAltitudeMode( mode );
65  } else if ( parentItem.is<GeoDataGroundOverlay>() ) {
66  parentItem.nodeAs<GeoDataGroundOverlay>()->setAltitudeMode( mode );
67  } else if ( parentItem.is<GeoDataAbstractView>() ) {
68  parentItem.nodeAs<GeoDataAbstractView>()->setAltitudeMode( mode );
69  } else if ( parentItem.is<GeoDataModel>() ) {
70  parentItem.nodeAs<GeoDataModel>()->setAltitudeMode( mode );
71  }
72 
73  return nullptr;
74 }
75 
76 }
77 }
78 }
@ RelativeToSeaFloor
Altitude is given relative to the sea floor.
Definition: MarbleGlobal.h:135
QString trimmed() const const
@ ClampToSeaFloor
Altitude always sticks to sea floor.
Definition: MarbleGlobal.h:136
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
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 Sep 25 2023 03:50:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.