Marble

KmlAltitudeModeTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
3 SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
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
25namespace Marble
26{
27namespace kml
28{
29KML_DEFINE_TAG_HANDLER( altitudeMode )
30
31GeoNode* 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}
Binds a QML item to a specific geodetic location in screen coordinates.
@ RelativeToGround
Altitude is always given relative to ground level.
@ ClampToGround
Altitude always sticks to ground level.
@ Absolute
Altitude is given relative to the sealevel.
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.