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
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
25namespace Marble
26{
27namespace kml
28{
29namespace gx
30{
31KML_DEFINE_TAG_HANDLER_GX22( altitudeMode )
32
33GeoNode* 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}
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 Fri Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.