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 "KmlElementDictionary.h"
11
12#include "GeoDataAbstractView.h"
13#include "GeoDataGeometry.h"
14#include "GeoDataGroundOverlay.h"
15#include "GeoDataLatLonAltBox.h"
16#include "GeoDataModel.h"
17#include "GeoDataPlacemark.h"
18#include "GeoDataPoint.h"
19#include "GeoDataTrack.h"
20
21#include "GeoParser.h"
22
23namespace Marble
24{
25namespace kml
26{
27KML_DEFINE_TAG_HANDLER(altitudeMode)
28
29GeoNode *KmlaltitudeModeTagHandler::parse(GeoParser &parser) const
30{
31 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(kmlTag_altitudeMode)));
32
33 QString content = parser.readElementText().trimmed();
34
35 AltitudeMode mode;
36 if (content == QLatin1StringView("relativeToGround")) {
37 mode = RelativeToGround;
38 } else if (content == QLatin1StringView("absolute")) {
39 mode = Absolute;
40 } else { // clampToGround is Standard
41 mode = ClampToGround;
42 }
43
44 GeoStackItem parentItem = parser.parentElement();
45
46 if (parentItem.is<GeoDataPlacemark>()) {
47 parentItem.nodeAs<GeoDataPlacemark>()->geometry()->setAltitudeMode(mode);
48 } else if (parentItem.is<GeoDataPoint>()) {
49 parentItem.nodeAs<GeoDataPoint>()->setAltitudeMode(mode);
50 } else if (parentItem.is<GeoDataLatLonAltBox>()) {
51 parentItem.nodeAs<GeoDataLatLonAltBox>()->setAltitudeMode(mode);
52 } else if (parentItem.is<GeoDataTrack>()) {
53 parentItem.nodeAs<GeoDataTrack>()->setAltitudeMode(mode);
54 } else if (parentItem.is<GeoDataGroundOverlay>()) {
55 parentItem.nodeAs<GeoDataGroundOverlay>()->setAltitudeMode(mode);
56 } else if (parentItem.is<GeoDataAbstractView>()) {
57 parentItem.nodeAs<GeoDataAbstractView>()->setAltitudeMode(mode);
58 } else if (parentItem.is<GeoDataModel>()) {
59 parentItem.nodeAs<GeoDataModel>()->setAltitudeMode(mode);
60 }
61
62 return nullptr;
63}
64
65}
66}
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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.