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(QLatin1StringView(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 auto 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 == QLatin1StringView("OpenStreetMap"))
69 serverLayout = new OsmServerLayout(texture);
70 else if (modeStr == QLatin1StringView("Custom"))
71 serverLayout = new CustomServerLayout(texture);
72 else if (modeStr == QLatin1StringView("WebMapService"))
73 serverLayout = new WmsServerLayout(texture);
74 else if (modeStr == QLatin1StringView("WebMapTileService"))
75 serverLayout = new WmtsServerLayout(texture);
76 else if (modeStr == QLatin1StringView("QuadTree"))
77 serverLayout = new QuadTreeServerLayout(texture);
78 else if (modeStr == QLatin1StringView("TileMapService")) {
79 storageLayout = GeoSceneTileDataset::TileMapService;
80 serverLayout = new TmsServerLayout(texture);
81 } else {
82 storageLayout = GeoSceneTileDataset::Marble;
83 serverLayout = new MarbleServerLayout(texture);
84
85 if (!modeStr.isEmpty()) {
86 mDebug() << "Unknown storage layout mode " << modeStr << ", falling back to default.";
87 }
88 }
89
90 texture->setLevelZeroColumns(levelZeroColumns);
91 texture->setLevelZeroRows(levelZeroRows);
92 texture->setMinimumTileLevel(minimumTileLevel);
93 texture->setMaximumTileLevel(maximumTileLevel);
94 texture->setTileLevels(tileLevels);
95 texture->setStorageLayout(storageLayout);
96 texture->setServerLayout(serverLayout);
97 }
98
99 return nullptr;
100}
101
102}
103}
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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.