Marble

DgmlProjectionTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7// Own
8#include "DgmlProjectionTagHandler.h"
9
10// Marble
11#include "DgmlAttributeDictionary.h"
12#include "DgmlElementDictionary.h"
13#include "GeoParser.h"
14#include "GeoSceneTileDataset.h"
15
16namespace Marble
17{
18namespace dgml
19{
20DGML_DEFINE_TAG_HANDLER(Projection)
21
22GeoNode* DgmlProjectionTagHandler::parse( GeoParser& parser ) const
23{
24 // Check whether the tag is valid
25 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Projection)));
26
27 // Checking for parent item
28 GeoStackItem parentItem = parser.parentElement();
29 if ( !parentItem.represents( dgmlTag_Texture ) && !parentItem.represents( dgmlTag_Vectortile))
30 return nullptr;
31
32 // Attribute name, default to "Equirectangular"
33 const QString nameStr = parser.attribute( dgmlAttr_name ).trimmed();
34 if ( !nameStr.isEmpty() ) {
35 GeoSceneAbstractTileProjection::Type tileProjectionType = GeoSceneAbstractTileProjection::Equirectangular;
36 if (nameStr == QLatin1String("Equirectangular")) {
37 tileProjectionType = GeoSceneAbstractTileProjection::Equirectangular;
38 } else if (nameStr == QLatin1String("Mercator")) {
39 tileProjectionType = GeoSceneAbstractTileProjection::Mercator;
40 } else {
41 parser.raiseWarning( QString( "Value not allowed for attribute name: %1" ).arg( nameStr ));
42 }
43
44 parentItem.nodeAs<GeoSceneTileDataset>()->setTileProjection(tileProjectionType);
45 }
46 return nullptr;
47}
48
49}
50}
Binds a QML item to a specific geodetic location in screen coordinates.
bool isEmpty() const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.