• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • handlers
  • dgml
DgmlStorageLayoutTagHandler.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
3 
4  This file is part of the KDE project
5 
6  This library is free software you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  aint with this library see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "DgmlStorageLayoutTagHandler.h"
23 
24 #include "MarbleDebug.h"
25 
26 #include "DgmlAttributeDictionary.h"
27 #include "DgmlElementDictionary.h"
28 #include "GeoParser.h"
29 #include "GeoSceneTiled.h"
30 #include "ServerLayout.h"
31 
32 namespace Marble
33 {
34 namespace dgml
35 {
36 DGML_DEFINE_TAG_HANDLER(StorageLayout)
37 
38 GeoNode* DgmlStorageLayoutTagHandler::parse(GeoParser& parser) const
39 {
40  // Check whether the tag is valid
41  Q_ASSERT(parser.isStartElement() && parser.isValidElement(dgmlTag_StorageLayout));
42 
43  // Attribute levelZeroColumns, default to value of the oldest tile themes
44  int levelZeroColumns = 2;
45  const QString levelZeroColumnsStr = parser.attribute(dgmlAttr_levelZeroColumns).trimmed();
46  if ( !levelZeroColumnsStr.isEmpty() ) {
47  levelZeroColumns = levelZeroColumnsStr.toInt();
48  }
49 
50  // Attribute levelZeroRows, default to value of the oldest tile themes
51  int levelZeroRows = 1;
52  const QString levelZeroRowsStr = parser.attribute(dgmlAttr_levelZeroRows).trimmed();
53  if ( !levelZeroRowsStr.isEmpty() ) {
54  levelZeroRows = levelZeroRowsStr.toInt();
55  }
56 
57  // Attribute maximumTileLevel
58  int maximumTileLevel = -1;
59  const QString maximumTileLevelStr = parser.attribute( dgmlAttr_maximumTileLevel ).trimmed();
60  if ( !maximumTileLevelStr.isEmpty() ) {
61  maximumTileLevel = maximumTileLevelStr.toInt();
62  }
63 
64  // Checking for parent item
65  GeoStackItem parentItem = parser.parentElement();
66  if (parentItem.represents(dgmlTag_Texture) || parentItem.represents(dgmlTag_Vectortile)) {
67  GeoSceneTiled *texture = parentItem.nodeAs<GeoSceneTiled>();
68 
69  // Attribute mode
70  GeoSceneTiled::StorageLayout storageLayout = GeoSceneTiled::OpenStreetMap;
71  ServerLayout *serverLayout = 0;
72  const QString modeStr = parser.attribute(dgmlAttr_mode).trimmed();
73  if ( modeStr == "OpenStreetMap" )
74  serverLayout = new OsmServerLayout( texture );
75  else if ( modeStr == "Custom" )
76  serverLayout = new CustomServerLayout( texture );
77  else if ( modeStr == "WebMapService" )
78  serverLayout = new WmsServerLayout( texture );
79  else if ( modeStr == "QuadTree" )
80  serverLayout = new QuadTreeServerLayout( texture );
81  else if ( modeStr == "TileMapService" )
82  {
83  storageLayout = GeoSceneTiled::TileMapService;
84  serverLayout = new TmsServerLayout( texture );
85  } else {
86  storageLayout = GeoSceneTiled::Marble;
87  serverLayout = new MarbleServerLayout( texture );
88 
89  if ( !modeStr.isEmpty() ) {
90  mDebug() << "Unknown storage layout mode " << modeStr << ", falling back to default.";
91  }
92  }
93 
94  texture->setLevelZeroColumns( levelZeroColumns );
95  texture->setLevelZeroRows( levelZeroRows );
96  texture->setMaximumTileLevel( maximumTileLevel );
97  texture->setStorageLayout( storageLayout );
98  texture->setServerLayout( serverLayout );
99  }
100 
101  return 0;
102 }
103 
104 }
105 }
DgmlAttributeDictionary.h
Marble::dgml::dgmlTag_StorageLayout
const char * dgmlTag_StorageLayout
Definition: DgmlElementDictionary.cpp:68
Marble::GeoSceneTiled::setServerLayout
void setServerLayout(const ServerLayout *)
Definition: GeoSceneTiled.cpp:86
DGML_DEFINE_TAG_HANDLER
#define DGML_DEFINE_TAG_HANDLER(Name)
Definition: DgmlElementDictionary.h:85
Marble::CustomServerLayout
Definition: ServerLayout.h:74
Marble::GeoStackItem::nodeAs
T * nodeAs()
Definition: GeoParser.h:120
Marble::QuadTreeServerLayout
Definition: ServerLayout.h:110
Marble::dgml::dgmlAttr_maximumTileLevel
const char * dgmlAttr_maximumTileLevel
Definition: DgmlAttributeDictionary.cpp:52
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoParser.h
DgmlStorageLayoutTagHandler.h
Marble::GeoSceneTiled
Definition: GeoSceneTiled.h:43
Marble::GeoSceneTiled::TileMapService
Definition: GeoSceneTiled.h:46
Marble::dgml::dgmlAttr_levelZeroColumns
const char * dgmlAttr_levelZeroColumns
Definition: DgmlAttributeDictionary.cpp:49
Marble::dgml::dgmlAttr_mode
const char * dgmlAttr_mode
Definition: DgmlAttributeDictionary.cpp:53
Marble::dgml::dgmlTag_Texture
const char * dgmlTag_Texture
Definition: DgmlElementDictionary.cpp:71
Marble::GeoSceneTiled::setLevelZeroColumns
void setLevelZeroColumns(const int)
Definition: GeoSceneTiled.cpp:102
MarbleDebug.h
Marble::GeoParser
Definition: GeoParser.h:40
Marble::GeoStackItem::represents
bool represents(const char *tagName) const
Definition: GeoParser.h:113
Marble::MarbleServerLayout
Definition: ServerLayout.h:47
QString::toInt
int toInt(bool *ok, int base) const
QString::isEmpty
bool isEmpty() const
QString::trimmed
QString trimmed() const
Marble::TmsServerLayout
Definition: ServerLayout.h:122
Marble::WmsServerLayout
Definition: ServerLayout.h:90
DgmlElementDictionary.h
Marble::GeoStackItem
Definition: GeoParser.h:97
QString
Marble::GeoSceneTiled::Marble
Definition: GeoSceneTiled.h:46
Marble::GeoSceneTiled::setStorageLayout
void setStorageLayout(const StorageLayout)
Definition: GeoSceneTiled.cpp:81
Marble::ServerLayout
Definition: ServerLayout.h:21
ServerLayout.h
Marble::OsmServerLayout
Definition: ServerLayout.h:60
Marble::dgml::dgmlTag_Vectortile
const char * dgmlTag_Vectortile
Definition: DgmlElementDictionary.cpp:76
Marble::dgml::DgmlStorageLayoutTagHandler
Definition: DgmlStorageLayoutTagHandler.h:32
GeoSceneTiled.h
Marble::GeoSceneTiled::StorageLayout
StorageLayout
Definition: GeoSceneTiled.h:46
Marble::GeoSceneTiled::OpenStreetMap
Definition: GeoSceneTiled.h:46
Marble::dgml::dgmlAttr_levelZeroRows
const char * dgmlAttr_levelZeroRows
Definition: DgmlAttributeDictionary.cpp:50
Marble::GeoSceneTiled::setLevelZeroRows
void setLevelZeroRows(const int)
Definition: GeoSceneTiled.cpp:112
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
Marble::GeoSceneTiled::setMaximumTileLevel
void setMaximumTileLevel(const int)
Definition: GeoSceneTiled.cpp:122
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal