Marble

KmlGxAltitudeModeTagHandler.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <sanjiban22393@gmail.com>
4//
5
6#include "KmlGxAltitudeModeTagHandler.h"
7
8#include "MarbleDebug.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{
27namespace gx
28{
29KML_DEFINE_TAG_HANDLER_GX22(altitudeMode)
30
31GeoNode *KmlaltitudeModeTagHandler::parse(GeoParser &parser) const
32{
33 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(kmlTag_altitudeMode)));
34
35 QString content = parser.readElementText().trimmed();
36
37 AltitudeMode mode;
38 if (content == QLatin1StringView("relativeToGround")) {
39 mode = RelativeToGround;
40 } else if (content == QLatin1StringView("absolute")) {
41 mode = Absolute;
42 } else if (content == QLatin1StringView("relativeToSeaFloor")) {
43 mode = RelativeToSeaFloor;
44 } else if (content == QLatin1StringView("clampToSeaFloor")) {
45 mode = ClampToSeaFloor;
46 } else if (content == QLatin1StringView("clampToGround")) {
47 mode = ClampToGround;
48 } else {
49 mDebug() << "Unknown altitude mode " << content << ", falling back to 'clampToGround'";
50 mode = ClampToGround;
51 }
52
53 GeoStackItem parentItem = parser.parentElement();
54
55 if (parentItem.is<GeoDataPlacemark>()) {
56 parentItem.nodeAs<GeoDataPlacemark>()->geometry()->setAltitudeMode(mode);
57 } else if (parentItem.is<GeoDataPoint>()) {
58 parentItem.nodeAs<GeoDataPoint>()->setAltitudeMode(mode);
59 } else if (parentItem.is<GeoDataLatLonAltBox>()) {
60 parentItem.nodeAs<GeoDataLatLonAltBox>()->setAltitudeMode(mode);
61 } else if (parentItem.is<GeoDataTrack>()) {
62 parentItem.nodeAs<GeoDataTrack>()->setAltitudeMode(mode);
63 } else if (parentItem.is<GeoDataGroundOverlay>()) {
64 parentItem.nodeAs<GeoDataGroundOverlay>()->setAltitudeMode(mode);
65 } else if (parentItem.is<GeoDataAbstractView>()) {
66 parentItem.nodeAs<GeoDataAbstractView>()->setAltitudeMode(mode);
67 } else if (parentItem.is<GeoDataModel>()) {
68 parentItem.nodeAs<GeoDataModel>()->setAltitudeMode(mode);
69 }
70
71 return nullptr;
72}
73
74}
75}
76}
Binds a QML item to a specific geodetic location in screen coordinates.
@ RelativeToGround
Altitude is always given relative to ground level.
@ ClampToSeaFloor
Altitude always sticks to sea floor.
@ ClampToGround
Altitude always sticks to ground level.
@ RelativeToSeaFloor
Altitude is given relative to the sea floor.
@ 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 Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.