Marble

DgmlProjectionTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <[email protected]>
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 
16 namespace Marble
17 {
18 namespace dgml
19 {
20 DGML_DEFINE_TAG_HANDLER(Projection)
21 
22 GeoNode* 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 }
QString trimmed() const const
bool isEmpty() const const
Binds a QML item to a specific geodetic location in screen coordinates.
Projection
This enum is used to choose the projection shown in the view.
Definition: MarbleGlobal.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Oct 4 2023 04:09:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.