• 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
  • writers
  • kml
KmlGroundOverlayWriter.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Shou Ya <shouyatf@gmail.com>
9 // Copyright 2012 Dennis Nienhüser <earthwings@gentoo.org>
10 //
11 
12 #include "KmlGroundOverlayWriter.h"
13 
14 #include "GeoDataGroundOverlay.h"
15 #include "GeoDataTypes.h"
16 #include "GeoWriter.h"
17 #include "KmlElementDictionary.h"
18 
19 namespace Marble
20 {
21 
22 static GeoTagWriterRegistrar s_writerLookAt(
23  GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataGroundOverlayType,
24  kml::kmlTag_nameSpaceOgc22 ),
25  new KmlGroundOverlayWriter );
26 
27 KmlGroundOverlayWriter::KmlGroundOverlayWriter() : KmlOverlayTagWriter( kml::kmlTag_GroundOverlay )
28 {
29  // nothing to do
30 }
31 
32 bool KmlGroundOverlayWriter::writeMid(const GeoNode *node, GeoWriter &writer) const
33 {
34  KmlOverlayTagWriter::writeMid( node, writer );
35 
36  const GeoDataGroundOverlay *ground_overlay =
37  static_cast<const GeoDataGroundOverlay*>( node );
38 
39  writer.writeOptionalElement( kml::kmlTag_altitude,
40  QString::number(ground_overlay->altitude()), "0" );
41  KmlGroundOverlayWriter::writeAltitudeMode( writer, ground_overlay->altitudeMode() );
42 
43  if ( !ground_overlay->latLonBox().isEmpty() ) {
44  writeElement( &ground_overlay->latLonBox(), writer );
45  }
46 
47  if ( ground_overlay->latLonQuad().isValid() ) {
48  writeElement( &ground_overlay->latLonQuad(), writer );
49  }
50 
51  return true;
52 }
53 
54 QString KmlGroundOverlayWriter::altitudeModeToString(AltitudeMode mode)
55 {
56  switch (mode) {
57  case ClampToGround:
58  return "clampToGround";
59  case RelativeToGround:
60  return "relativeToGround";
61  case ClampToSeaFloor:
62  return "clampToSeaFloor";
63  case RelativeToSeaFloor:
64  return "relativeToSeaFloor";
65  case Absolute:
66  return "absolute";
67  }
68  return "";
69 }
70 
71 void KmlGroundOverlayWriter::writeAltitudeMode(GeoWriter& writer, AltitudeMode altMode)
72 {
73  if ( altMode == ClampToGround ) {
74  // clampToGround is always the default value, so we never have to write it
75  return;
76  }
77 
78  const QString altitudeMode = KmlGroundOverlayWriter::altitudeModeToString( altMode );
79  bool const isGoogleExtension = ( altMode == ClampToSeaFloor || altMode == RelativeToSeaFloor );
80  if ( isGoogleExtension ) {
81  // clampToSeaFloor and relativeToSeaFloor are Google extensions that need a gx: tag namespace
82  writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_altitudeMode, altitudeMode);
83  } else {
84  writer.writeElement( kml::kmlTag_altitudeMode, altitudeMode );
85  }
86 }
87 
88 }
89 
Marble::GeoDataGroundOverlay::altitudeMode
AltitudeMode altitudeMode() const
Definition: GeoDataGroundOverlay.cpp:87
Marble::GeoWriter::writeOptionalElement
void writeOptionalElement(const QString &key, const QString &value, const QString &defaultValue=QString())
Convenience method to write value if value is not equal to defaultValue.
Definition: GeoWriter.cpp:98
Marble::kml::kmlTag_nameSpaceGx22
const char * kmlTag_nameSpaceGx22
Definition: KmlElementDictionary.cpp:35
Marble::GeoDataLatLonBox::isEmpty
virtual bool isEmpty() const
Indicates whether the bounding box is not initialised (and contains nothing).
Definition: GeoDataLatLonBox.cpp:768
Marble::KmlGroundOverlayWriter::writeAltitudeMode
static void writeAltitudeMode(GeoWriter &writer, AltitudeMode altitudeMode)
Definition: KmlGroundOverlayWriter.cpp:71
Marble::s_writerLookAt
static GeoTagWriterRegistrar s_writerLookAt(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataGroundOverlayType, kml::kmlTag_nameSpaceOgc22), new KmlGroundOverlayWriter)
Marble::Absolute
Altitude is given relative to the sealevel.
Definition: MarbleGlobal.h:150
GeoDataGroundOverlay.h
Marble::KmlGroundOverlayWriter::writeMid
bool writeMid(const GeoNode *node, GeoWriter &writer) const
Definition: KmlGroundOverlayWriter.cpp:32
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::KmlGroundOverlayWriter::altitudeModeToString
static QString altitudeModeToString(AltitudeMode mode)
Definition: KmlGroundOverlayWriter.cpp:54
Marble::ClampToSeaFloor
Altitude always sticks to sea floor.
Definition: MarbleGlobal.h:152
Marble::kml::kmlTag_altitudeMode
const char * kmlTag_altitudeMode
Definition: KmlElementDictionary.cpp:41
Marble::GeoDataLatLonQuad::isValid
bool isValid() const
Definition: GeoDataLatLonQuad.cpp:195
Marble::KmlOverlayTagWriter
Definition: KmlOverlayTagWriter.h:23
Marble::GeoDataTypes::GeoDataGroundOverlayType
const char * GeoDataGroundOverlayType
Definition: GeoDataTypes.cpp:44
KmlGroundOverlayWriter.h
Marble::GeoDataGroundOverlay::latLonBox
GeoDataLatLonBox & latLonBox() const
Definition: GeoDataGroundOverlay.cpp:97
Marble::GeoWriter::writeElement
void writeElement(const QString &namespaceUri, const QString &key, const QString &value)
Convenience method to write value with key prefixed format namespaceUri.
Definition: GeoWriter.cpp:84
GeoWriter.h
QString::number
QString number(int n, int base)
Marble::RelativeToGround
Altitude is always given relative to ground level.
Definition: MarbleGlobal.h:149
KmlElementDictionary.h
Marble::AltitudeMode
AltitudeMode
Definition: MarbleGlobal.h:147
Marble::KmlGroundOverlayWriter::KmlGroundOverlayWriter
KmlGroundOverlayWriter()
Definition: KmlGroundOverlayWriter.cpp:27
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:29
Marble::GeoTagWriter::QualifiedName
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:48
QString
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoTagWriter::writeElement
bool writeElement(const GeoNode *object, GeoWriter &writer) const
Definition: GeoTagWriter.cpp:29
Marble::GeoDataGroundOverlay::latLonQuad
const GeoDataLatLonQuad & latLonQuad() const
Definition: GeoDataGroundOverlay.cpp:112
Marble::KmlOverlayTagWriter::writeMid
virtual bool writeMid(const GeoNode *node, GeoWriter &writer) const =0
Definition: KmlOverlayTagWriter.cpp:28
Marble::ClampToGround
Altitude always sticks to ground level.
Definition: MarbleGlobal.h:148
Marble::GeoDataGroundOverlay
Definition: GeoDataGroundOverlay.h:24
Marble::kml::kmlTag_altitude
const char * kmlTag_altitude
Definition: KmlElementDictionary.cpp:40
GeoDataTypes.h
Marble::RelativeToSeaFloor
Altitude is given relative to the sea floor.
Definition: MarbleGlobal.h:151
Marble::kml::kmlTag_GroundOverlay
const char * kmlTag_GroundOverlay
Definition: KmlElementDictionary.cpp:79
Marble::GeoDataGroundOverlay::altitude
double altitude() const
Definition: GeoDataGroundOverlay.cpp:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 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