Marble

DgmlStorageLayoutTagHandler.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#include "DgmlStorageLayoutTagHandler.h"
8
9#include "MarbleDebug.h"
10
11#include "DgmlAttributeDictionary.h"
12#include "DgmlElementDictionary.h"
13#include "GeoParser.h"
14#include "GeoSceneTileDataset.h"
15#include "ServerLayout.h"
16
17namespace Marble
18{
19namespace dgml
20{
21DGML_DEFINE_TAG_HANDLER(StorageLayout)
22
23GeoNode* DgmlStorageLayoutTagHandler::parse(GeoParser& parser) const
24{
25 // Check whether the tag is valid
26 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_StorageLayout)));
27
28 // Attribute levelZeroColumns, default to value of the oldest tile themes
29 int levelZeroColumns = 2;
30 const QString levelZeroColumnsStr = parser.attribute(dgmlAttr_levelZeroColumns).trimmed();
31 if ( !levelZeroColumnsStr.isEmpty() ) {
32 levelZeroColumns = levelZeroColumnsStr.toInt();
33 }
34
35 // Attribute levelZeroRows, default to value of the oldest tile themes
36 int levelZeroRows = 1;
37 const QString levelZeroRowsStr = parser.attribute(dgmlAttr_levelZeroRows).trimmed();
38 if ( !levelZeroRowsStr.isEmpty() ) {
39 levelZeroRows = levelZeroRowsStr.toInt();
40 }
41
42 // Attribute minimumTileLevel
43 int minimumTileLevel = 0;
44 const QString minimumTileLevelStr = parser.attribute( dgmlAttr_minimumTileLevel ).trimmed();
45 if ( !minimumTileLevelStr.isEmpty() ) {
46 minimumTileLevel = minimumTileLevelStr.toInt();
47 }
48
49 // Attribute maximumTileLevel
50 int maximumTileLevel = -1;
51 const QString maximumTileLevelStr = parser.attribute( dgmlAttr_maximumTileLevel ).trimmed();
52 if ( !maximumTileLevelStr.isEmpty() ) {
53 maximumTileLevel = maximumTileLevelStr.toInt();
54 }
55
56 // Attribute maximumTileLevel
57 const QString tileLevels = parser.attribute( dgmlAttr_tileLevels ).trimmed();
58
59 // Checking for parent item
60 GeoStackItem parentItem = parser.parentElement();
61 if (parentItem.represents(dgmlTag_Texture) || parentItem.represents(dgmlTag_Vectortile)) {
62 GeoSceneTileDataset *texture = parentItem.nodeAs<GeoSceneTileDataset>();
63
64 // Attribute mode
65 GeoSceneTileDataset::StorageLayout storageLayout = GeoSceneTileDataset::OpenStreetMap;
66 ServerLayout *serverLayout = nullptr;
67 const QString modeStr = parser.attribute(dgmlAttr_mode).trimmed();
68 if (modeStr == QLatin1String("OpenStreetMap"))
69 serverLayout = new OsmServerLayout( texture );
70 else if (modeStr == QLatin1String("Custom"))
71 serverLayout = new CustomServerLayout( texture );
72 else if (modeStr == QLatin1String("WebMapService"))
73 serverLayout = new WmsServerLayout( texture );
74 else if (modeStr == QLatin1String("WebMapTileService"))
75 serverLayout = new WmtsServerLayout( texture );
76 else if (modeStr == QLatin1String("QuadTree"))
77 serverLayout = new QuadTreeServerLayout( texture );
78 else if (modeStr == QLatin1String("TileMapService"))
79 {
80 storageLayout = GeoSceneTileDataset::TileMapService;
81 serverLayout = new TmsServerLayout( texture );
82 } else {
83 storageLayout = GeoSceneTileDataset::Marble;
84 serverLayout = new MarbleServerLayout( texture );
85
86 if ( !modeStr.isEmpty() ) {
87 mDebug() << "Unknown storage layout mode " << modeStr << ", falling back to default.";
88 }
89 }
90
91 texture->setLevelZeroColumns( levelZeroColumns );
92 texture->setLevelZeroRows( levelZeroRows );
93 texture->setMinimumTileLevel( minimumTileLevel );
94 texture->setMaximumTileLevel( maximumTileLevel );
95 texture->setTileLevels( tileLevels );
96 texture->setStorageLayout( storageLayout );
97 texture->setServerLayout( serverLayout );
98 }
99
100 return nullptr;
101}
102
103}
104}
Binds a QML item to a specific geodetic location in screen coordinates.
bool isEmpty() const const
int toInt(bool *ok, int base) const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:50:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.